Re: unicode text coercion to number bug?
Re: unicode text coercion to number bug?
- Subject: Re: unicode text coercion to number bug?
- From: Mark Butcher <email@hidden>
- Date: Tue, 14 Sep 2004 12:10:19 -0700
Several people replied, and I'd like to respond to all here:
The problem originated with an AS Studio project that has unicode text
as an input. The simple lines of code I'd posted reproduced the problem
in the simplest way I could think of.
Several pointed out that you shouldn't rely on automatic coercions
unless you are 100% sure of them. I had tested this with divide, and it
worked, so I assumed it would automatically coerce with multiply also.
My point is that it should either work for _both_ multiply and divide,
or not. My own feeling in this case is that it should not work. But how
can you ever be 100% sure anyway? Test for all the math operators (in
this case) to see if they all work? We assume that if it works for one
math operator, it works for the others. If not, it's a bug.
MarkB
On Sep 14, 2004, at 4:07 AM, Nigel Garvey wrote:
Richard Morton wrote on Tue, 14 Sep 2004 17:35:47 +1000:
I think Mark got his examples the wrong way around:
(1.2 as Unicode text) / 3 --> 0.4
(1.2 as Unicode text) * 3 --> AppleScript Error. Can't make "1.2" into
a number.
I get the same result as this under 10.3.3.
It seems to be something to do specifically with Unicode text and with
the amount and kind of automatic coercion required. There's no problem
with plain text or when the Unicode text represents an integer or a
whole
real. When it represents a fractional real, the only operator that
works
is '/', which is also the only operator that knows in advance that both
its operands have to be reals. There's no problem either if the number
is
presented before the Unicode text:
3 * (1.2 as Unicode text) --> 3.6
NG
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden