• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Possible bug.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


  • Follow-Ups:
    • Re: Possible bug.
      • From: Deivy Petrescu <email@hidden>
References: 
 >Possible bug. (From: Deivy Petrescu <email@hidden>)

  • Prev by Date: Possible bug.
  • Next by Date: Re: Possible bug.
  • Previous by thread: Possible bug.
  • Next by thread: Re: Possible bug.
  • Index(es):
    • Date
    • Thread