Re: Applescript oddity under 10.4.11
Re: Applescript oddity under 10.4.11
- Subject: Re: Applescript oddity under 10.4.11
- From: Doug McNutt <email@hidden>
- Date: Tue, 20 Apr 2010 14:33:27 -0600
At 12:06 -0500 4/20/10, Stockly, Ed wrote:
Content-Language: en-US
Content-Type: multipart/alternative;
boundary="_000_C7F32D159483edstocklylatimescom_"
In 10.4.11, when I try to compile this:
set valeur to valeur * 0.423333320617684
SNIP by DPM
There is a fundamental limit to the precision of floats and doubles. For a double, which AppleScript surely uses fails after 52 bits. A fraction like 0.1000 (10) is not exactly representable being a repeating sequence that looks like:
0.000110011001100110011... (2) forever. Think 1/16 + 1/32 + 1/256 + 1/512 . . . on a US ruler calibrated in fractions of an inch.
In the same way 1/3 in decimal is 0.3333333...(10) forever.
52 bits is about the same as 15 decimal digits but the exact value depends on the number.
I would bet that AppleScript is getting confused. There is also something about Applescript that refuses to use all 32 bits of a long integer. Some high order bit is likely being set to indicate that the value is actually a floating double. It's also possible that some bit in a double is doing something similar. If so the limit might be less than 52 bits. Its also possible that differences would show up in 64 vs 32 bit hardware.
--
Applescript syntax is like English spelling:
Roughly, though not thoroughly, thought through.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden