Arithmetic: the is predicate and the comparison predicates
 

This version of Strawberry Prolog has integer arithmetic only. Nevertheless we describe all the arithmetic within plans here. Just do expect to find that part of it is not available yet.

Arithmetical expressions are built up using

· the following infix binary operators :

+, -, *, /, rem, mod, **, >>, <<, /\, \/

They stand for addition , substraction , multiplication , division , remainder , modulo , bit-shifts leftward and rightward , and bitwise andand or , respectively.

· the following unary operators

(unary minus) -, \

They stand for negation and bitwise complement , respecively.

Ordinary (prefix) syntax is the only option for

abs(Number) absolute value
atan(Number) arctangent
ceiling(Number) smallest integer not smaller than Number
cos(Number) cosine
exp(Number) eNumber
sign(Number) -1 , 0 or 1 for negative, zero, or positive Number
float(Number) explicit conversion to floating point
floor(Float) largest integer not greater than Number
log(Number) natural logarithm
sin(Number) sine
truncate(Float) the integer with the greatest absolute value,

not greater than that of Float , and signed like Float

round(Float) the integer nearest to 'Float

Trigonometrical functions admit arguments in radians , atan produces result in radians too.

There are two cases, in which arithmetical expressions get evaluated . One case comes with the is operator

X is Expression

causes the evaluation of Expression and instantiating variable X to the result. The other case are the occurrences of the comparison predicates:

Number1 =:= Number2 Number1 equal to Number2
Number1 =\= Number2 Number1 not equal to Number2
Number1 < Number2 Number1 greater than Number2
Number1 > Number2 Number1 less than Number2
Number1 <= Number2 Number2 not less than Number1
Number1 >= Number2 Number2 not greater than Number1

Both arguments of these predicates are expected to be arithmetical expressions and get evaluated before comparison takes place.