Strange math behaviour... could someone explain this ?

Ken Ray kray at sonsothunder.com
Fri Oct 7 18:39:50 EDT 2005


On 10/7/05 2:30 PM, "jbv" <jbv.silences at Club-Internet.fr> 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 ?

I don't know about that, but perhaps the docs should say that coercing the
number back into a string (by adding "") would make the trunc() function
"more right". ;-)

That is, if you had:

  put (C*100) & "" into C  -- coerces to a string
  put trunc(C)

You should always get 180...

Ken Ray
Sons of Thunder Software
Web site: http://www.sonsothunder.com/
Email: kray at sonsothunder.com




More information about the use-livecode mailing list