Math problems?

J. Landman Gay jacque at hyperactivesw.com
Sat May 20 20:04:21 EDT 2006


Mark Wieder wrote:
> Peter-
> 
> Friday, May 19, 2006, 12:04:55 PM, you wrote:
> 
>> I am doing the following:
> 
>> put 10.27 into tNumber
>> put the trunc of tNumber into tInteger
>> put tNumber - tInteger into tDecimal
>> put 100 * tDecimal into tNew Decimal
>> put the trunc of tNewDecimal
> 
>> and I get 26 instead of 27.
> 
>   put trunc(tNewDecimal & "")
> 
> forcing it into a string does the trick. Better yet,
> 
> function truncate pValue
>   return trunc(pValue & "")
> end truncate
> 
> Note: this is BZ #2419, which for some reason Tuviah closed as
> NOT_A_BUG in January 2004, so unless Jacque reopens it it's unlikely
> that it will be fixed.
> 

After it was explained to me, I agreed it isn't a bug. It is how math 
works. See Dar's explanation, which is pretty good.

By the way, I just tried the original script (quoted at the top above,) 
using Mac OS 10.4.6 and I did not get 26, I got 27 as expected. I 
suspect it is system-related. I believe the Rev engine relies on the 
OS's math routines to get its results.

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com



More information about the use-livecode mailing list