MOD function does not work! So be warned!

David Vaughan drvaughan55 at
Fri Mar 29 00:17:01 EST 2002

On Friday, March 29, 2002, at 03:43 , Dar Scott wrote:

> On Thursday, March 28, 2002, at 09:06 PM, David Vaughan wrote:
>> Interesting bug. I changed your startpoint and endpoint to 4.9 & 5 
>> with no bug and 4.8 & 5 with the bug.
>> Changing the critical line to "put loop && round(loop) mod 5 & return 
>> after msg" disposes of the error so I it seems to be a trailing digits 
>> error in real arithmetic rather than a logical bug as such. "5 mod 5" 
>> of course always produces 0.
> This is discouraging.  I typed ".2 + .2 + .2 + .2 + .2 = 10 into the 
> message window and got false.
So did I but my discouragement was alleviated by typing ".2 + .2 + .2 + 
.2 + .2 = 1"  !!    :-)

> I assume by real you mean floating point, as typically implemented by 
> computer hardware, a number with a binary point.  I don't see anything 
> in the documentation as numbers being sometimes implemented as floating 
> point.

I don't know about the documentation but I mean with a sign, mantissa 
and exponent rather than BCD or integer. You can force this format, I 
believe, by taking an integer and raising it to a power, e.g.
put 4^1 into x
makes x a floating point number in the terms I suggest. If the number 
were BCD then I would not expect the failure Ian discovered, any more 
than you would for integer. Mod, incidentally, is (or was) intended as 
an integer function rather than one for real (floating point) numbers.
> I wouldn't mind this if it is transparent.  As long as a value looks 
> and acts like a string, I don't care how it is stored internally.
> As far as rounding, without evidence to the contrary one would have to 
> assume that numbers are rounded to a decimal point rather than to a 
> binary point.  (Numbers don't have to be represented in decimal for a 
> decimal point to be maintained, but they often are.)
> The implication is that applications that need a decimal point need to 
> have lots of special code.

Not really. Treat it as one of string, integer or floating point (s, m, 
e) and BCD or "binary point" can take care of themselves.

Incidentally, we are still working on that comparative challenge you set 
us, Dar.


> Dar Scott
> _______________________________________________
> use-revolution mailing list
> use-revolution at

More information about the use-livecode mailing list