0
What is a modulus operator like how can i can find the result of a modulus operation without the program what operation is it?
3 Réponses
+ 1
Thanks man
+ 1
Modulus is the remainder of two integers being divided. For example, 5 / 2 = 2 (since integers are floored). However 5 % 2 = 1, since 2 can go into 5 twice evenly leaving a remainder of 1.
Some more scratch work:
5 - 2 = 3
3 - 2 = 1
1 is the remainder. This can also be found doing long division. Another simple example, 4 % 2 = 0 since it can be evenly divided. Also one more is that 1 % 3 = 1 since 3 cannot divide into 1.