Operator MOD
#50
Maybe this SUPER simple formula will show how it works:

Code: (Select All)
For i = -10 To 10
    Print Steve_ModX(i, 5), Steve_ModX2(i, 5), Steve_ModX3(i, 5)
Next


Function Steve_ModX (num1, num2)
    Steve_ModX = ((num1 Mod num2) + Abs(num2)) Mod num2
End Function


Function Steve_ModX2 (num1, num2)
    Steve_ModX2 = num1 - (Int(num1 / num2) * num2)
End Function

Function Steve_ModX3 (num1, num2)
    Steve_ModX3 = num1 - (num1 \ num2) * num2
End Function


And this even showcases how QB64 gets the answer that it goes for us, with ModX3.  

INT(x / y) is NOT the same as x \ y.
Reply


Messages In This Thread
Operator MOD - by Chris - 11-27-2022, 07:09 PM
RE: Operator MOD - by Pete - 11-27-2022, 07:35 PM
RE: Operator MOD - by Chris - 11-27-2022, 07:47 PM
RE: Operator MOD - by SMcNeill - 11-27-2022, 08:03 PM
RE: Operator MOD - by Chris - 11-27-2022, 08:17 PM
RE: Operator MOD - by Pete - 11-27-2022, 08:23 PM
RE: Operator MOD - by Chris - 11-27-2022, 08:30 PM
RE: Operator MOD - by SMcNeill - 11-27-2022, 08:44 PM
RE: Operator MOD - by mnrvovrfc - 11-27-2022, 08:32 PM
RE: Operator MOD - by bplus - 11-27-2022, 08:42 PM
RE: Operator MOD - by Chris - 11-27-2022, 08:54 PM
RE: Operator MOD - by SMcNeill - 11-27-2022, 08:57 PM
RE: Operator MOD - by SMcNeill - 11-27-2022, 09:02 PM
RE: Operator MOD - by Jack - 11-27-2022, 09:02 PM
RE: Operator MOD - by Chris - 11-27-2022, 09:02 PM
RE: Operator MOD - by SMcNeill - 11-27-2022, 09:06 PM
RE: Operator MOD - by Chris - 11-27-2022, 09:08 PM
RE: Operator MOD - by Chris - 11-27-2022, 09:14 PM
RE: Operator MOD - by Jack - 11-27-2022, 09:18 PM
RE: Operator MOD - by Pete - 11-27-2022, 09:23 PM
RE: Operator MOD - by Chris - 11-27-2022, 09:28 PM
RE: Operator MOD - by Chris - 11-27-2022, 09:52 PM
RE: Operator MOD - by Pete - 11-27-2022, 10:41 PM
RE: Operator MOD - by mnrvovrfc - 11-28-2022, 01:17 AM
RE: Operator MOD - by mnrvovrfc - 11-28-2022, 04:01 AM
RE: Operator MOD - by mnrvovrfc - 11-28-2022, 02:57 AM
RE: Operator MOD - by Pete - 11-28-2022, 03:21 AM
RE: Operator MOD - by Jack - 11-28-2022, 10:13 AM
RE: Operator MOD - by Kernelpanic - 11-28-2022, 04:03 PM
RE: Operator MOD - by Jack - 11-28-2022, 11:56 AM
RE: Operator MOD - by Chris - 11-28-2022, 03:21 PM
RE: Operator MOD - by Chris - 11-28-2022, 04:06 PM
RE: Operator MOD - by Pete - 11-28-2022, 07:02 PM
RE: Operator MOD - by mnrvovrfc - 11-28-2022, 08:23 PM
RE: Operator MOD - by SMcNeill - 11-28-2022, 09:54 PM
RE: Operator MOD - by mnrvovrfc - 11-28-2022, 10:10 PM
RE: Operator MOD - by Pete - 11-28-2022, 10:23 PM
RE: Operator MOD - by Kernelpanic - 11-29-2022, 11:12 PM
RE: Operator MOD - by SMcNeill - 11-28-2022, 10:33 PM
RE: Operator MOD - by Kernelpanic - 11-28-2022, 11:46 PM
RE: Operator MOD - by mnrvovrfc - 11-29-2022, 12:10 AM
RE: Operator MOD - by Pete - 11-29-2022, 12:00 AM
RE: Operator MOD - by Kernelpanic - 11-29-2022, 12:05 AM
RE: Operator MOD - by SMcNeill - 11-29-2022, 12:35 AM
RE: Operator MOD - by Kernelpanic - 11-29-2022, 12:25 AM
RE: Operator MOD - by Pete - 11-29-2022, 12:36 AM
RE: Operator MOD - by bplus - 11-29-2022, 01:29 AM
RE: Operator MOD - by Pete - 11-29-2022, 01:42 AM
RE: Operator MOD - by bplus - 11-29-2022, 04:41 AM
RE: Operator MOD - by SMcNeill - 11-29-2022, 06:24 AM
RE: Operator MOD - by SMcNeill - 11-29-2022, 06:34 AM
RE: Operator MOD - by bplus - 11-29-2022, 12:27 PM
RE: Operator MOD - by Pete - 11-29-2022, 11:58 PM
RE: Operator MOD - by Kernelpanic - 11-30-2022, 02:50 AM
RE: Operator MOD - by SMcNeill - 11-30-2022, 03:49 AM
RE: Operator MOD - by Kernelpanic - 12-01-2022, 12:41 AM
RE: Operator MOD - by vince - 11-30-2022, 12:41 PM
RE: Operator MOD - by Chris - 12-03-2022, 08:19 AM
RE: Operator MOD - by SMcNeill - 12-03-2022, 08:31 AM
RE: Operator MOD - by Pete - 12-03-2022, 09:06 AM
RE: Operator MOD - by mnrvovrfc - 12-03-2022, 11:56 AM
RE: Operator MOD - by SMcNeill - 12-03-2022, 12:08 PM
RE: Operator MOD - by Kernelpanic - 12-03-2022, 05:07 PM
RE: Operator MOD - by Pete - 12-03-2022, 05:12 PM
RE: Operator MOD - by Kernelpanic - 12-03-2022, 05:20 PM
RE: Operator MOD - by SMcNeill - 12-03-2022, 12:30 PM
RE: Operator MOD - by mnrvovrfc - 12-03-2022, 12:31 PM
RE: Operator MOD - by Pete - 12-03-2022, 03:31 PM
RE: Operator MOD - by DSMan195276 - 12-03-2022, 05:57 PM
RE: Operator MOD - by Kernelpanic - 12-03-2022, 06:48 PM
RE: Operator MOD - by Pete - 12-03-2022, 06:05 PM



Users browsing this thread: 23 Guest(s)