11-28-2022, 03:31 AM
(11-28-2022, 02:46 AM)bplus Wrote: Yeah so what's -7 mod -5 ? Sorry I think this is funny
I figured the possibility of using negative MOD values into my MODX function. Note, these are not correct MOD values for negative numbers, the function merely preserves the pattern.
Code: (Select All)
FOR i = 5 TO -7 STEP -1
PRINT i, modx(i, -5)
NEXT
FUNCTION modx (i, j)
IF SGN(i) < 0 THEN
IF ABS(i) <> ABS(j) THEN modx = (ABS(j) - ABS(i MOD j)) ELSE modx = 0
ELSE
modx = i MOD j
END IF
END FUNCTION
Pete