HTBasic Help
×
Menu
Index

MODULO

Returns the true mathematical modulus.
 
 dividend MODULO divisor
 
Usage:
I=D MODULO 16
PRINT "Inches" =";Length MODULO 12
R=12 MODULO –5
 
Example:           MODULO.BAS
 
Description:
X MODULO Y is the remainder from a division which produces an integral quotient and is defined as X - Y * INT(X/Y),. If one or both of the operands are REAL, the result is REAL; otherwise the result is INTEGER.
 
Note that MODULO is similar to MOD but gives a different result only when X/Y is negative. This is because MODULO uses the formula X - Y * INT(X/Y), whereas MOD uses X - Y * (X DIV Y). This means when X/Y is negative INT(X/Y) converts to integer by truncation toward negative infinity, whereas  (X DIV Y) in MOD converts to integer by truncation toward zero.
 
See Also: