Operator MOD - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: Chatting and Socializing (https://qb64phoenix.com/forum/forumdisplay.php?fid=11) +--- Forum: General Discussion (https://qb64phoenix.com/forum/forumdisplay.php?fid=2) +--- Thread: Operator MOD (/showthread.php?tid=1195) |
RE: Operator MOD - Chris - 11-27-2022 SMcNeill Can you complete this formula with data: -7 MOD 5 so that the result is displayed as a variable: PRINT A # Chris RE: Operator MOD - SMcNeill - 11-27-2022 (11-27-2022, 08:54 PM)Chris Wrote: SMcNeill Code: (Select All) A# = ModAll(-7, 5) RE: Operator MOD - SMcNeill - 11-27-2022 Remember, MOD takes the closest multiple of your number, and then gives the remainder. So 13 MOD 5... 10 is the closest multiple of 5... 13 - 10 = 3 In the case of -7 MOD 5... -5 is the closest multiple of 5... -7 - -5 = -2 MOD is giving the proper results by this logic. You're just not used to thinking of it in such a manner. RE: Operator MOD - Jack - 11-27-2022 Code: (Select All) $Console:Only result Code: (Select All) -1 RE: Operator MOD - Chris - 11-27-2022 My point is to supplement your code with numerical data. So where to enter -7 and 5. I want the result obtained in the variable A #. Chris RE: Operator MOD - SMcNeill - 11-27-2022 (11-27-2022, 09:02 PM)Chris Wrote: My point is to supplement your code with numerical data. So where to enter -7 and 5. I want the result obtained in the variable A #. https://qb64phoenix.com/forum/showthread.php?tid=1195&pid=10746#pid10746 -- If that doesn't work for you, then it just can't be done. You might need to try swapping over to COBOL to get your desired results. RE: Operator MOD - Chris - 11-27-2022 Jack There is only one correct result. Chris RE: Operator MOD - Chris - 11-27-2022 SMcNeil There is only one correct result. Chris RE: Operator MOD - Jack - 11-27-2022 Chris, in your view what are the correct results? and what's your reference? Code: (Select All) $Console:Only result Code: (Select All) -1 RE: Operator MOD - Pete - 11-27-2022 Trying to come up with something other than what's been posted... Code: (Select All) FOR i = 5 TO -7 STEP -1 |