Arithmetic

KEY Arithmetic is performed by built-in procedures which take as arguments integer expressions and evaluate them. An integer expression is a term built from evaluable functors, integers and variables. At the time of evaluation, each variable in an integer expression must be bound to an integer or to an integer expression. Each evaluable functor stands for an arithmetic operation. The evaluable functors are as follows, where X and Y are integer expressions. X+Y integer addition X-Y integer subtraction X*Y integer multiplication X/Y integer division X mod Y X modulo Y -X unary minus X/\Y bitwise conjunction X\/Y bitwise disjunction X<<Y bitwise left shift of X by Y places X>>Y bitwise right shift of X by Y places [X] (a list of just one element) evaluates to X if X is an integer. Since a quoted string is just a list of integers, this allows a quoted character to be used in place of its ASCII code; e.g. "A" behaves within arithmetic expressions as the integer 65. The arithmetic built-in procedures are as follows, where X and Y stand for arithmetic expressions, and Z for some term. Note that this means that is only evaluates one of its arguments as an integer expression (i.e. X), whereas all the comparison predicates evaluate both their arguments. Z is X Integer expression X is evaluated and the result, is unified with Z. Fails if X is not an integer expression. X =:= Y The values of X and Y are equal. X =\= Y The values of X and Y are not equal. X < Y The value of X is less than the value of Y. X > Y The value of X is greater than the value of Y. X =< Y The value of X is less than or equal to the value of Y. X >= Y The value of X is greater than or equal to the value of Y.