Arithmetic MODULUS Operator

The % operator is a binary (infix) arithmetic MODULUS operator. The % operator expects an integer right hand operand and an integer left hand operand. If either operand is a string, it will be automatically coerced to an integer before the MODULUS operator is applied.

The / integer DIVISION operator truncats any fractional component of its result and returns only an integer. The MODULUS operator returns the remainder of the integer division N / M

i.e.
	((N / M) * M) + (N % M) == N

 

syntax:

	<left_expr> % <right_expr>

<left_expr> and <right_expr> are refered to as the left and right operand respectively and may themselves be simple values or complex expressions.

e.g.
	0x1234 % 16			yields 4

	10 % 3				yields 1

	(5 + 7) % 8			yields 4