Remainder(n, d) Better than MOD, same as capping wrapping?
#8
Barely remember that MOD operator thread that went a ridiculous number of posts, and something about it. This is something I have used many times programming in BASIC and in Lua. Where [n] is the dividend and when the answer requires [1,n] and not [0,n-1].

Code: (Select All)
FUNCTION modslide~&& (divi AS _UNSIGNED _INTEGER64, dsor AS _UNSIGNED _INTEGER64)
    'the following line should be to report an error in calculation:
    IF dsor = 0 THEN modslide = 0 : EXIT FUNCTION
    modslide = ((divi - 1) MOD dsor) + 1
END FUNCTION
Reply


Messages In This Thread
RE: Remainder(n, d) Better than MOD, same as capping wrapping? - by mnrvovrfc - 12-31-2022, 02:07 AM



Users browsing this thread: 2 Guest(s)