MODULO

Synopsis
MODULO dividend divisor
Description

Outputs the remainder of dividing dividend divided by divisor. Both dividend and divisor must be numbers and divisor must not be 0.

Mathematically, a remainder is a number such that

dividend = quotient * divisor + remainder

Where quotient is an integer and -divisor < remainder < divisor. By this definition, two remainders may be possible for a given divisor and dividend, one positive and one negative. To make MODULO well-defined, it always outputs the remainder whose sign matches that of divisor. In contrast, REMAINDER uses the sign of dividend.

Example
SHOW MODULO 5 3
2
SHOW MODULO -5 3
1
SHOW MODULO 3.8 1.2
0.2

SourceForge.net Logo