Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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

Possibly Related Threads…
Thread Author Replies Views Last Post
  Mod'ing a classic- partial circle fill OldMoses 6 1,297 01-17-2023, 07:11 PM
Last Post: bplus
  A single line function to modify MOD for better pattern recognition.... Pete 4 1,171 11-29-2022, 12:53 AM
Last Post: Pete

Forum Jump:


Users browsing this thread: 1 Guest(s)