[TIB] [Fwd: Re: modulus]


[Prev][Next][Index][Thread]

[TIB] [Fwd: Re: modulus]




 

the modulus is the remainder when the number to the left of the '%' is divided by the number to the
right ...

Examples:

10 % 2 = 0

10 is divided by 2 evenly, so there is no remainder

153 % 10 = 3

153 divided by 10 is 15R3, so the result of the '%' operator is 3

29 % 6 = 5

29 divided by 6 is 4R5, so the result is 5


In general, the result of the mod operator (%) is strictly less than the number on the
right of the '%' sign (because the remainder of a division problem is always strictly less
than the divisor)