because the standard order of precedence means that the unary minus is performed before the modulus.
I have edited the above statement because the original was a mistake and didn't match the first line. Sorry about that, I should read my posts more carefully.
Answers
-1 mod 4 should return -1
because the standard order of precedence means that the unary minus is performed before the modulus.
I have edited the above statement because the original was a mistake and didn't match the first line. Sorry about that, I should read my posts more carefully.
Hmmm... That's not what I see! b-(
AFAIK, all unary operators have higher precedence than any other binary operators.
Both for programming & mathematics!!! ~:>
Modulo binary operator % should never happen before negative unary operator -!!! 8-X
i always (n + m) % m (which only works if n is never going below -m, which it isn't, usually)
(((n % m) + m) % m) should work. longwinded though.
Excellent @koogs! o=>
@koogs of course - looking for wrap around values - well spotted