MOD function does not work! So be warned!

Rob Cozens rcozens at pon.net
Sun Mar 31 13:47:01 EST 2002


>What is it about loops that affects this so?

Richard, et al:

I don't know if this helps to root out the bug, but try:

on testMod
   put 249 into var1
   put var1 into var2
   add 1.0 to var1
   repeat 10
     add 0.1 to var2
   end repeat
   put (var1=var2)&&((var1 mod 5)=(var2 mod 5))
end testMod

This handler seems to fail with most initial values and mod values. 
To get a list of those values between 1 & 200 that don't fail for mod 
values of 1 thru 10, try:

on testMod2
   put empty into goodList
   repeat with x = 1 to 10
     repeat with y = 1 to 200
       put y into var1
       put var1 into var2
       add 1.0 to var1
       repeat 10
         add 0.1 to var2
       end repeat
       if (var1 mod x)<>(var2 mod x) then next repeat
       put var1&&"mod"&&x&&"is OK"&return after goodList
     end repeat
   end repeat
   put goodList -- best to create a scrolling field & put goodList into it
end testMod2

Maybe someone less mathematically-challenged than moi can find a pattern here?
-- 

Rob Cozens
CCW, Serendipity Software Company
http://www.oenolog.com/who.htm

"And I, which was two fooles, do so grow three;
Who are a little wise, the best fooles bee."

from "The Triple Foole" by John Donne (1572-1631)



More information about the use-livecode mailing list