Operator % Foundation
Modulus operator (binary): determines the remainder of a division.
Syntax
<nValue1> % <nValue2>
Parameters
<nValue1>
<nValue1> is a numeric expression, whose value is the numerator of the division.
<nValue2>
<nValue2> is a numeric expression whose value is the denominator of the division. The value of <nValue2> may not be zero.
Description
The result of the modulus operator is the remainder of the division of <nValue1> by <nValue2> (as a numeric value).
Examples
// This example demonstrates various modulus operations.
PROCEDURE Main
? -1 % 3 // result: -1
? 1 % -3 // result: 1
? -2 % 3 // result: -2
? 2 % -3 // result: 2
? 3 % -2 // result: 1
? -3 % 2 // result: -1
? 3 % 2 // result: 1
? -3 % -2 // result: -1
? 27 % 6 // result: 3
? 27 % 3 // result: 0
? 27 % 2 // result: 1
? 27 % 30 // result: 27
? 3.2 % 2.1 // result: 1.10
? 3 % 0 // result: runtime error
RETURN
Feedback
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.