Remainder(n, d) Better than MOD, same as capping wrapping? - Printable Version +- QB64 Phoenix Edition (https://staging.qb64phoenix.com) +-- Forum: QB64 Rising (https://staging.qb64phoenix.com/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://staging.qb64phoenix.com/forumdisplay.php?fid=3) +---- Forum: Utilities (https://staging.qb64phoenix.com/forumdisplay.php?fid=8) +---- Thread: Remainder(n, d) Better than MOD, same as capping wrapping? (/showthread.php?tid=1227) Pages:
1
2
|
RE: Remainder(n, d) Better than MOD, same as capping wrapping? - bplus - 12-31-2022 (12-31-2022, 04:39 AM)PhilOfPerth Wrote:(12-03-2022, 05:22 PM)bplus Wrote: Break this?I didn't see Chia Pet's post, but toggle = 1 - toggle always gives result=toggle; to toggle between 1 and 0 shouldn't it be toggle = Abs(toggle - 1) ? You might be assuming toggle takes on -1 value like QB64's True value, no. Toggle is only ever 0 or 1 specially if DIM's as an integer as opposed a float. RE: Remainder(n, d) Better than MOD, same as capping wrapping? - bplus - 12-31-2022 (12-31-2022, 03:59 AM)SMcNeill Wrote: Why not just make 2 distinct mods which you can then call upon to get the output in whatever format you want? I don't know if this is reply to me or Minerva. If to me I gotta ask why is 2 functions more than 2 lines long better than 1 function 2 lines long? I remind all that I started thread with spec that remainder needs to be between 0 and divisor. So why use ABS? RE: Remainder(n, d) Better than MOD, same as capping wrapping? - SMcNeill - 12-31-2022 @Bplus That's my point though -- Why that spec? Why not just use both functions and then have a choice in however you want the answer to be formatted? RE: Remainder(n, d) Better than MOD, same as capping wrapping? - bplus - 12-31-2022 The spec is for when conditions of program call for a value between 0 and the denominator. Comes up often in keeping an object inside the boundaries of a Basic screen. Of course I can only think of positive divisors because they are really distances. MOD does not work when the object moves out heading left or heading up and the divisor is the Width or Height of screen. I will now answer my own question. What breaks this is trying to apply it to situation where 0 is neither the low nor high limit eg keeping a number between -5 and 100 say. |