Operators: %

Modulo division (remainder) operator.

Syntax

integer‑operand%integer‑operand

Integer modulo division

The % operator divides the left integer operand by the right integer operand and returns the remainder left over. If used in combination with 8-, 16- or 32-bit signed integer operands, the data type resulting from the operation is consequently int32. When mixing signed and unsigned integer operands, the operation results in the unsigned uint32 value. In the case, one of the operands is 64-bit large, the resulting data type is int64 or uint64 according to whether the 64-bit operand is signed or unsigned. Please note, trying to perform the division with the right operand == 0 (zero) will raise a 'division by zero' runtime CPU exception. For example:

var int32  a = 2500;
var int32  b = -7;
var uint32 c = 1098;
var uint32 d = 57;
var uint64 e =  897546641189;
var int64  f = -149613691251;

var int32  result = a % b; // result = 1
var uint32 result = c % d; // result = 15
var uint32 result = b % d; // result = 18 (overflow)
var int64  result = f % d; // result = -51
var uint64 result = e % d; // result = 32