PLOGHELP DIVIDE Kathryn Seifert October 1986
Updated A.Sloman April 1987
Operator to divide two numbers
?- X is / .
Keywords: division, arithmetic expressions, arithmetic, evaluation
To divide numbers, use the division sign "/", with the operator
"is":
?- X is 12/3.
X = 4 ?
If the result is not an integer it will be a RATIO. By default, ratios
in Prolog print as decimals, thus:
?- X is 10/3.
X = 3.333333 ?
You can over-ride this default by setting the POP-11 variable
POP_PR_RATIOS true in your init.p file before running Prolog,
(see HELP * INITIAL) thus:
true -> pop_pr_ratios;
After which the following behaviour will be observed:
?- X is 10/3.
X = 10_/3 ?
You can force "/" to produce a decimal result rather than a ratio by
using a decimal number as one of the arguments, e.g.
?- X is 10/3.0.
X = 3.33333 ?
If the POP-11 variable POPDPRECISION is true the result will not be a
decimal but a ddecimal. Its default is false, but this default can be
over-ridden in your init.p file
true -> popdprecision;
NOTE:
If ratios or ddecimals are used instead of only integers and
decimals then this can cause extra garbage collections to occur, since
ratios and ddecimals are allocated off the heap, unlike integers and
single decimals which fit into one machine long-word. For more on this
see REF * EFFICIENCY
-- RELATED DOCUMENTATION -----------------------------------------------
PLOGHELP * ARITHMETIC
Overview of HELP files dealing with operations on numbers.
PLOGHELP * IS
Evaluating POP-11 and arithmetic expressions which return one result
PLOGHELP * SYMBOLS
Summary and index of HELP files for symbols used in Prolog
PLOGHELP * OPERATORS
Operator declarations made when the Prolog system is loaded
PLOGHELP * OP
How to declare operators
REF * NUMBERS
Overview of implementation of numbers in POPLOG
REF * DATA
Overview of data types in POPLOG
REF * EFFICIENCY
--- C.all/plog/help/divide ---------------------------------------------
--- Copyright University of Sussex 1987. All rights reserved. ----------