Availability:Arithmetic function (see is/2)
[ISO]+Expr1 / +Expr2Result = Expr1/Expr2. If the
flag iso is true
or one of the arguments is a float, both arguments are converted to
float and the return value is a float. Otherwise the result type depends
on the Prolog flag
prefer_rationals.
If true
, the result is always a rational number. If false
the result is rational if at least one of the arguments is rational.
Otherwise (both arguments are integer) the result is integer if the
division is exact and float otherwise. See also section
4.27.2.2, ///2, and rdiv/2.
The current default for the Prolog flag prefer_rationals
is
false
. Future version may switch this to true
,
providing precise results when possible. The pitfall is that in general
rational arithmetic is slower and can become very slow and produce huge
numbers that require a lot of (global stack) memory. Code for which the
exact results provided by rational numbers is not needed should force
float results by making one of the operants float, for example by
dividing by
10.0
rather than 10
or by using float/1.
Note that when one of the arguments is forced to a float the division is
a float operation while if the result is forced to the float the
division is done using rational arithmetic.