Numeric values
Prolog supports traditional integer and floating point numeric expressions.
It provides a variety of functions to test if a variable or atom has a specific
numeric subtype, e.g. number(X), integer(X), float(X)
, etc.
Functions and operators
Numerous conventional binary and unary operators are supported:
Note: when using "is", the item on the left must be an
uninstantiated variable (i.e. a variable with no value yet) and the item
on the right must be a value or an expression that can be evaluated
to a value (i.e. no uninstantiated variables on the right hand side).
This means that expressions like X is (X + 1) cannot possibly
work, since if X has a value it is invalid on the left side, and if it doesn't
have a value then it is invalid on the right side.
+ -
+ - * / // ^ >> mod rem xor
Comparison and type-checking functions
Functions that take both the data and result as parameters
Many of these are variants on the math functions discussed above,
e.g. sqrt(Num,Result), floor(Num,Result), etc.
Note that the return value of these is a typical prolog true/false.