### User Tools

A PCRE internal error occured. This might be caused by a faulty plugin

# Differences

This shows you the differences between two versions of the page.

 cl:functions:mod [2019/07/14 17:00] cl:functions:mod [2020/05/30 08:00] (current) Line 1: Line 1: + ====== Function MOD, REM ====== + + ====Syntax==== + * **mod** //number divisor// → //​modulus// ​ + * **rem** //number divisor// → //​remainder//​ + + ====Arguments and Values==== + * //number// - a //​[[CL:​Glossary:​real]]//​. + * //divisor// - a //​[[CL:​Glossary:​real]]//​. + * //​modulus//,​ //​remainder//​ - a //​[[CL:​Glossary:​real]]//​. + + ====Description==== + **mod** and **rem** are generalizations of the modulus and remainder functions respectively. + + **mod** performs the operation **[[CL:​Functions:​floor]]** on //number// and //divisor// and returns the remainder of the **[[CL:​Functions:​floor]]** operation. + + **rem** performs the operation **[[CL:​Functions:​truncate]]** on //number// and //divisor// and returns the remainder of the **[[CL:​Functions:​truncate]]** operation. + + **mod** and **rem** are the modulus and remainder functions when //number// and //divisor// are //​[[CL:​Glossary:​integers]]//​. + + ====Examples==== ​ + <​blockquote> ​ + (rem -1 5) -1 + (mod -1 5) 4 + (mod 13 4) 1 + (rem 13 4) 1 + (mod -13 4) 3 + (rem -13 4) -1 + (mod 13 -4) -3 + (rem 13 -4) 1 + (mod -13 -4) -1 + (rem -13 -4) -1 + (mod 13.4 1) <​r>​0.4 + (rem 13.4 1) <​r>​0.4 + (mod -13.4 1) <​r>​0.6 + (rem -13.4 1) <​r>​-0.4 + ​ + + ====Side Effects==== + None. + + ====Affected By==== + None. + + ====Exceptional Situations==== + None. + + ====See Also==== + * **[[CL:​Functions:​floor|Function FLOOR]]** + * **[[CL:​Functions:​truncate|Function TRUNCATE]]** + + ====Notes==== + The result of **mod** is either zero or a //​[[CL:​Glossary:​real]]//​ with the same sign as //​divisor//​. + + \issue{REAL-NUMBER-TYPE:​X3J13-MAR-89}