Re: div bug
Re: div bug
- Subject: Re: div bug
- From: Doug McNutt <email@hidden>
- Date: Tue, 4 Aug 2009 15:39:24 -0600
At 22:02 +0200 8/4/09, julifos wrote:
>So, when I coerce to small real, AppleScript is rounding (from 8 to 4 bytes)
>the number (instead of truncating) and that's because I get the desired
>result?
>
>Someone should write the rulez in the ASLG ;--)
Actually the change is more like 52 bits to 23 bits of precision.
Doubles are a sign bit (sign and magnitude), 11 bits of exponent (power of 2, -1022 to +1023), and 52 bits of a normalized value between 1/2 and 1. Since the first bit is always 1 it is really not present.
Small real or single is a sign bit, 8 bits of exponent, and 23 bits of normalized value.
As with all standards changes are in the works with IEEE-754 (2008). Support for decimal arithmetic and rounding are being "improved".
When you change from double to single you almost surely are executing a hardware command buried in the microprocessor. What really happens may well depend on what Intel did in the design phase and it might also depend on which version of IEEE-754 was in the hands of the designer.
So it's not AppleScript this time. Here it's Motorola. There it's Intel. Both have had to create software workarounds for floating point logic errors discovered after distribution.
I once prepared a talk on binary representations and the figures are still on an ftp site.
<ftp://ftp.macnauchtan.com/PPLUG/Binary.pdf> 496 kB is the whole thing.
Directory <ftp://ftp.macnauchtan.com/PPLUG/> has individual pages including Float32 and Float64
--
--> From the U S of A, the only socialist country that refuses to admit it. <--
_______________________________________________
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
References: | |
| >Re: div bug (From: julifos <email@hidden>) |