
rem(+Number1, +Number2, -Result)
-Result is +Number1 rem +Number2

   Evaluates the remainder Number1 rem Number2 and unifies the resulting value
with Result.



Arguments
   Number1             Integer.
   Number2             Integer.
   Result              Output: integer.

Type
   Arithmetic

Description

    Evaluates the remainder Number1 rem Number2 and unifies the resulting value
    with Result.

    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.

   This predicate can be used as a function in arithmetic expressions.
   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.


Modes and Determinism
   rem(+, +, -) is det

Exceptions
     4 --- Number1 or Number2 is not instantiated (non-coroutining mode    only).
     5 --- Number1 or Number2 is a number but not an integer.
    20 --- Illegal arithmetic operation: Number2 is zero
    24 --- Number1 or Number2 is not of a numeric type.

Examples
   
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


See Also
   is / 2, // / 3, mod / 3
