Re:Integers in C quiz
by masklinn on Sunday September 04, 2022 @09:28AM
(#32712816)
> What's "wat" (in the same sense as the js "wat" talk) is that the answer changes if the argument becomes negative.
It's the same in Python though? you just prefer the way it behaves (though to be fair it's generally more useful and less troublesome): Python's remainder follows the sign of the divisor (because it uses floored division), while C's follows the sign of the dividend (because it uses truncated division).
Strictly speaking, neither is an euclidian modulo.
Re:Integers in C quiz
by owl57 on Sunday September 04, 2022 @10:56AM
(#32713738)
It's not symmetric. I believe most people with strong mathematical background (like Guido:)) expect lambda x: x % m to be some "computer approximation" to the standard mapping from Z to Z/mZ, while not having deep expectations about lambda m: x % m.
It's the same in Python though? you just prefer the way it behaves (though to be fair it's generally more useful and less troublesome): Python's remainder follows the sign of the divisor (because it uses floored division), while C's follows the sign of the dividend (because it uses truncated division).
Strictly speaking, neither is an euclidian modulo.