Re: magic integer converter number 62?
Re: magic integer converter number 62?
- Subject: Re: magic integer converter number 62?
- From: John W Baxter <email@hidden>
- Date: Mon, 19 Feb 2001 18:23:39 -0800
At 17:36 -0800 2/19/01, M Shaw wrote:
>
Can anybody figure out why this works:
>
>
set x to 62
>
set b to ((x + (2.6 - (2.6 mod 1))) - x) as integer
>
>
and this doesn't:
>
>
set x to 61
>
set b to ((x + (2.6 - (2.6 mod 1))) - x) as integer
My problem is that I can't immediately figure out why the first form
"works" (produces 2 rather than an error about not being able to make
[approximately] 2.0 into an integer).
Let's look at this smaller part of the puzzle:
set c to 2.6 - (2.6 mod 1)
c - 2
The result is not 0, it is the small non-zero number
5.77315972805081E-15
That's because 2.6 cannot be represented exactly as a binary floating point
number...neither can 0.6. The Mac is doing the best it can, but the values
2.6 and 0.6 don't exist...they have to be approximated.
--John
--
John Baxter email@hidden Port Ludlow, WA, USA