Re: Possible bug.
Re: Possible bug.
- Subject: Re: Possible bug.
- From: Paul Berkowitz <email@hidden>
- Date: Sun, 02 May 2004 17:55:55 -0700
On 5/2/04 5:33 PM, "Deivy Petrescu" <email@hidden> wrote:
>
First script
>
>
set x to ((1 / (2 ^ 2 + 1)))
>
try
>
run script x
>
on error
>
"x is " & x
>
end try
>
>
---0.2
>
>
Second script
>
>
set x to ((1 / (2 ^ 3 + 1)))
>
try
>
run script x
>
on error
>
"x is " & x
>
end try
>
>
---"x is 0.111111111111"
>
>
It happens with a bunch of numbers.
>
Smells like a bug, looks like a bug and walks like a bug, is it a bug?
Not really, just an inconsistent implicit coercion. 'run script' takes a
string as an argument and you're giving it numerical fractions. It can deal
with the rational fraction 1/5 = 0.2 OK, coercing it to "0.2". But it has
trouble with the irrational 1/9, probably because the usual answer we get
(0.111111111111) is a rounding that needs an evaluation first by explicit
coercion':
run script ((1 / 9) as string)
--> 0.111111111111
set x to ((1 / (2 ^ 3 + 1)) as string) -- or:
-- set x to ("" & (1 / (2 ^ 3 + 1)))
try
run script x
on error
"x is " & x
end try
--> 0.111111111111
--
Paul Berkowitz
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.