numerical bug

Dar Scott dsc at
Sat Mar 30 11:50:01 EST 2002

On Saturday, March 30, 2002, at 08:30 AM, Ivers, Doug E wrote:

> Please be aware that  put 10^-1
> yields
> 0.10000000000000000555

> This is a bug.  I'll code a workaround for now and assume that 
> this will be fixed in the next release of Rev.
Look at the recent discussion "MOD function does not work" and 
"Binary Floating Point".

This is a natural consequence of the Revolution engine (Metacard) 
using binary floating point for values that are the result of math 
functions.  (Plus, any limitations of the ^ function.)  The use of 
floating point probably speeds a series of math operations, notably 
those in loops.  At processor speeds available in the early days of 
Metacard, this may have been a serious consideration.

I don't think we can expect a change here in the next release of 
Revolution unless something has been in the works for a while.  The 
best we might hope for in the short run is better binary floating 

I proposed a number change on the "improve" list.  It is a major 
change and is not 100% backward compatible.

You might be able to live with Revolution numbers as they are.  
Remember you are limited to about 17 digits.  Even when you seem to 
be using numbers with less than that, they are only accurate to 
that; assume every number has an error.  Avoid = and use <, <=, >= 
or > instead, when you can.  Use (x + empty) to force rounding as 
specified in numberFormat, if you need it.  This forces the 
internal representation to string (which can be used as a number 
again).  Use it for =, also.  You can also use round() and 
trunc().  The round function allows you to specify number of digits 
beyond the decimal point.

Dar Scott

More information about the use-livecode mailing list