number % 2
#2

This is the modulus and calculates the remainder of a division. It is frequently used to check if a number is odd or even.

6 / 2 returns a whole number (3), and thus the remainder is 0. (3 * 2 = 6).
6 / 4 returns 1 and the remainder is 2. (1 * 4 + 2 = 6).
Reply


Messages In This Thread
number % 2 - by Supercop - 01.07.2012, 14:48
Re: number % 2 - by Vince - 01.07.2012, 14:51
Re: number % 2 - by Hiddos - 01.07.2012, 14:52

Forum Jump:


Users browsing this thread: 1 Guest(s)