Strange math behaviour... could someone explain this ?

Alex Tweedly alex at tweedly.net
Fri Oct 7 16:15:28 EDT 2005


jbv wrote:

> Nevertheless, how do you explain that the following :
>
>  put 36 into A
>  put 34.2 into B
>  put A-B into C
>
>  put C*100 into C
>  put trunc(C)
>
>returns 180 with Rev 2.5 on Mac OS9, but returns 179 on other
>platforms such as Linux or Win2000 ?
>
>Just curious...
>  
>
I was curious about that too.

What's the hardware involved in each case ? Are they all the same ?

It could be differences in the floating-point hardware (or floating 
point emulation library).
Or it could be difference in the library used by Rev to convert from the 
text string into fp format (if it chose a different value for the last 
bit, it would be "180+tiny delta" instead of 180-tiny delta" (once 
multiplied by 100) and then the trunc() call would get a different answer. 

Remember they may *both* be considered correct answers, depending on the 
binary representation used by different machines / libraries.
(Sigh. I don't like it either Jonathan - but after 34 years of computing 
in a wide variety of languages, I'm getting used to it :-)

(I'm hoping that the OS9 machine is an old Motorola based machine, 
rather than a PPC-based and Intel-based machine, and that I can use that 
as my answer :-) :-)   Though come to think of it, even if it's a modern 
Mac (i.e. PPC) that may be different enough from the Linux/Win machines 
you tried.

-- 
Alex Tweedly       http://www.tweedly.net



-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.11.13/123 - Release Date: 06/10/2005




More information about the use-livecode mailing list