good one
Does '%' mean either "mod" or "rem" in C?
In C %mean it will give remainder not mod
First of all modulo and % are different so stop calculating it on google calculator ( google calculator is calculating a modulo b )
7 % 3 --> 1
7 % -3 --> 1
-7 % 3 --> -1
-7 % -3 --> -1
Modulo as Euclidean division The wiki Euclidean division asserts 0 ≤ r < |b| which means the remainder aka "modulo operation." is always at least 0
7 modulo 3 --> 1
7 modulo -3 --> 1
-7 modulo 3 --> 2
-7 modulo -3 --> 2
|
Google uses a different definition of modulo
|
7 modulo 3 --> 1
7 modulo -3 --> -2
-7 modulo 3 --> 2
-7 modulo -3 --> -1
coming to actual question how you calculate a% b , remember in result of a%b will take sign of numerator , so you have to just calculate a%b as you do it for positive numbers , then see numerator i.e. a sign if sign of a is negative then put (-) with your answer , else if a is positive no need to do anythinh
Thank you !!