+ 1

/ and %

Modulus operator gives the remainder and the division operator gives the quotient. So how is it possible that:- -16 / -3 = 5 BUT -16 % -3 = -1 According to me, both the answers should have same sign.

30th Jan 2017, 6:46 PM
Sarthak Mathur
Sarthak Mathur - avatar
2 ответов
+ 2
No. Because 5 * -3 is -15 and you need -1 to get to -16, which actually is the remainder of this division
30th Jan 2017, 6:51 PM
Nikolai Russev
Nikolai Russev - avatar
+ 1
Thanks Nikolai.
30th Jan 2017, 7:02 PM
Sarthak Mathur
Sarthak Mathur - avatar