+ 2
What's the actual algebraic algorithm the modulo function uses? How does it work with one negative and one positive operand?
Modulo
2 Antworten
+ 4
From the docs: "The modulo operator always yields a result with the same sign as its second operand (or zero); the absolute value of the result is strictly smaller than the absolute value of the second operand."
See more at:
https://docs.python.org/3/reference/expressions.html#binary-arithmetic-operations
0
modulo finds the remaining amount. what i have found by playing around is -6%4 returns 2 whereas -6%-4 returns -2
the algorithm is just like long division except you stop before turning to decimal values and look at how much is remaining