Operator % Foundation
Modulus operator (binary): determines the remainder of a division.
<nValue1> % <nValue2>
The result of the modulus operator is the remainder of the division of <nValue1> by <nValue2> (as a numeric value).
// 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
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.