>>> MODn(y , x) = y - x * INT(y / x)
Another nice integer modula formula, but I'd tweak it to handle negative mods...
Pete
Another nice integer modula formula, but I'd tweak it to handle negative mods...
Code: (Select All)
$CONSOLE:ONLY
x = 5
FOR y = 20 TO -20 STEP -1
PRINT y; MODn(y, x)
NEXT
FUNCTION MODn (y, x)
MODn = y - ABS(x) * INT(y / ABS(x))
END FUNCTION
Pete