Petit Computer Wiki
Register
Advertisement

% is the BASIC operator for modulo arithmetic. A%B gives the remainder after A has been divided by B.

Unlike some implementations of BASIC, B may be a noninteger. Also, B may be negative, but the result given is the same as if it were positive. Of course, B must be nonzero, otherwise the system will generate an error: Division by zero.

If A is positive, the result is positive (or zero), and if A is negative, the result is negative (or zero).

Advertisement