MOD function does not work! So be warned!

David Vaughan drvaughan55 at mac.com
Thu Mar 28 23:08:01 EST 2002


On Friday, March 29, 2002, at 02:53 , Ian Summerfield wrote:

> The code I give here might look inefficient, the code comes from a large
> project, so there are reasons for doing it this way!
>
> It's just taken me several hours to figure out why my code wasn't 
> working,
> and it turns out to be a bug in Revolution.
>
> Revolution 1.1.1b2 (OS X 10.1.3) seems to think 5 mod 5 = 5 whereas it 
> is
> zero.

> on mouseup
>   put 235 into startPoint
>   put 255 into endPoint
>   put 0.1 into increment
>   put empty into msg
>   put startPoint into loop
>   repeat while loop<=endPoint
>     put loop && loop mod 5 & return after msg
>     add increment to loop
>   end repeat
> end mouseup
>
ian

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.

cheers
David




More information about the use-livecode mailing list