Topic: DMD0120 MATH Modulus / Remainder Operator |
||||||||||||||||||
|
||||||||||||||||||
The Modulus / Remainder operator ( % ) will perform modulo division on a numerator and a denominator. The result of a modulo division is the remainder of an integer division of the given positive numerator and denominator. All calculations are performed using integer division meaning that even if the numerator or denominator are Real numbers only the integer portion of the Real value is used in the calculation.
Modulo division using negative integer values for either the numerator or denominator is undefined, so if the parameters are memory locations consider using the ABS() math function to guarantee that only positive integers are used in the division calculation. Attempting to perform a division calculation when the denominator is 0 will generate a quotient of 0 and a "Divide by Zero - $DivideByZero (ST141)" error.
The numerator and denominator can be any mix of signed integers, unsigned integers, real (floating point) numbers or discrete values. They can be any numeric or discrete memory location or any numeric or discrete structure member.
Traditional math precedence rules are used to solve the math expression, The use of parentheses to remove any ambiguity in the processing order is encouraged.
Refer to the examples below:
|
||||||||||||||||||
|
||||||||||||||||||
See Also:
Modulus / Remainder
|
||||||||||||||||||
|
||||||||||||||||||
Related Topics:
|
||||||||||||||||||
|