Break this?
For ideal modulus, I imagine it should be between 0 and the divisor = modulus whether divisor is pos or negative.
I read johannhowitzer Wrapping, capping and other... and it all fell in place what we are trying to reach, keeping numbers between 0 and the divisor whether integer or float like Pi, we just want a proper remainder.
BTW best toggle I've seen and used often from Chia Pet:
toggle = 1 - toggle
For ideal modulus, I imagine it should be between 0 and the divisor = modulus whether divisor is pos or negative.
I read johannhowitzer Wrapping, capping and other... and it all fell in place what we are trying to reach, keeping numbers between 0 and the divisor whether integer or float like Pi, we just want a proper remainder.
Code: (Select All)
_Title "Remainder test" ' b+ for a modulus that always returns a number between 0 and divisor
' if divisor is negative then return a rational between 0 and some rational d < 0
' if divisor is positive then return a rational between 0 and some rational d > 0
' if divisor is 0 ? can't divide by 0
' Do we need to round? Doesn't look like it but I just ran a couple quick tests. Folks here can find fault with anything! ;-))
' NOTE: when testing don't leave space between , and d eg, do 5,3 not 5, 3
$Console:Only
Do
Input "0's quit, please enter n, d to find remainder n/d between 0 and d "; n, d
If (n = 0) Or (d = 0) Then End
Print Remainder##(n, d)
Print
Loop
' modeled on MODn
'ref Pete https://staging.qb64phoenix.com/showthread.php?tid=1195&pid=10983#pid10983
Function Remainder## (n##, d##)
If d## = 0 Then Exit Function
Remainder## = n## - (d##) * Int(n## / (d##))
End Function
BTW best toggle I've seen and used often from Chia Pet:
toggle = 1 - toggle
b = b + ...