1. Modulo Arithmetic #

Created Monday 22 June 2020

Modular arithmetic is a system of arithmetic for integers, which considers the remainder. In modular arithmetic, numbers “wrap around” upon reaching a given fixed quantity (this given quantity is known as the modulus) to leave a remainder.

15 mod(9) = 6 (-15) mod 9 = 3


Applications of the % operator:

  1. To avoid overflow.

e.g long long is 8 bytes, i.e 2^63^-1 is the maximum number it can store.