Result is Number1 rem Number2which should be preferred for portability.
The modulus operation computes the remainder corresponding to the truncating division //. The following relation always holds:
X =:= (X rem Y) + (X // Y) * Y.The result Result is either zero, or has the same sign as Number1. The absolute value of Result does not depend on the signs of the arguments.
In coroutining mode, if Number1 or Number2 are uninstantiated, the call to rem/3 is delayed until these variables are instantiated.
See also the mod operation, whose result only differs when the arguments have opposite signs.
Success: X is 10 rem 3. % gives X = 1 X is -10 rem 3. % gives X = -1 X is 10 rem -3. % gives X = 1 X is -10 rem -3. % gives X = -1 Error: rem(2, 0, Result). % arithmetic exception