DAY 020: MOD
#5
(11-28-2022, 02:46 AM)bplus Wrote: Yeah so what's -7 mod -5 ? Sorry I think this is funny  Big Grin

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
Reply


Messages In This Thread
DAY 020: MOD - by SMcNeill - 11-28-2022, 02:00 AM
RE: DAY 020: MOD - by mnrvovrfc - 11-28-2022, 02:28 AM
RE: DAY 020: MOD - by TerryRitchie - 11-28-2022, 02:32 AM
RE: DAY 020: MOD - by bplus - 11-28-2022, 02:46 AM
RE: DAY 020: MOD - by Pete - 11-28-2022, 03:31 AM
RE: DAY 020: MOD - by Pete - 11-28-2022, 04:11 AM
RE: DAY 020: MOD - by vince - 11-28-2022, 01:45 PM
RE: DAY 020: MOD - by OldMoses - 11-28-2022, 08:36 PM



Users browsing this thread: 1 Guest(s)