Availability:built-in
divmod(+Dividend,
+Divisor, -Quotient, -Remainder)This predicate is a shorthand for computing both the Quotient
and
Remainder of two integers in a single operation. This allows
for exploiting the fact that the low level implementation for computing
the quotient also produces the remainder. Timing confirms that this
predicate is almost twice as fast as performing the steps independently.
Semantically, divmod/4
is defined as below.
divmod(Dividend, Divisor, Quotient, Remainder) :-
Quotient is Dividend div Divisor,
Remainder is Dividend mod Divisor.
Note that this predicate is only available if SWI-Prolog is compiled
with unbounded integer support. This is the case for all packaged
versions.