Steve, yours needs some work if you pop a negatives in there as the modulo.
Pete
Code: (Select All)
$CONSOLE:ONLY
PRINT "Equation Steve's Results | Pete's Results"
PRINT
FOR i = 10 TO -10 STEP -1 ' Modulo 5
PRINT i; "mod 5 =";: LOCATE , 18: PRINT Steve_ModX(i, 5), , Pete_modx(i, 5)
NEXT
PRINT "----------------------Negative Mods----------------------"
FOR i = 10 TO -10 STEP -1 ' Modulo -5
PRINT i; "mod -5 =";: LOCATE , 18: PRINT Steve_ModX(i, -5), , Pete_modx(i, -5)
NEXT
FUNCTION Pete_modx (i, j)
Pete_modx = (ABS(i) - ABS(j) * ((ABS(i) \ ABS(j)) + (1 - SGN(i)) \ 2)) * SGN(i MOD j)
END FUNCTION
FUNCTION Steve_ModX (num1, num2)
Steve_ModX = ((num1 MOD num2) + num2) MOD num2
END FUNCTION
Pete
If eggs are brain food, Biden takes his scrambled.