|Did you know ...||Search Documentation:|
In modern Prolog systems, arithmetic constraints subsume and supersede low-level predicates over integers. The main advantage of arithmetic constraints is that they are true relations and can be used in all directions. For most programs, arithmetic constraints are the only predicates you will ever need from this library.
The most important arithmetic constraint is #=/2,
which subsumes both
(=:=)/2 over integers. Use #=/2
to make your programs more general. See declarative integer arithmetic (section
In total, the arithmetic constraints are:
Expr1 equals Expr2 Expr1
Expr1 is not equal to Expr2 Expr1
Expr1 is greater than or equal to Expr2 Expr1
Expr1 is less than or equal to Expr2 Expr1
Expr1 is greater than Expr2 Expr1
Expr1 is less than Expr2
Expr1 and Expr2 denote arithmetic expressions, which are:
integer Given value variable Unknown integer ?(variable) Unknown integer -Expr Unary minus Expr + Expr Addition Expr * Expr Multiplication Expr - Expr Subtraction Expr
Minimum of two expressions
Maximum of two expressions Expr
Modulo induced by floored division Expr
Modulo induced by truncated division
Absolute value Expr
Truncated integer division Expr div Expr Floored integer division
where Expr again denotes an arithmetic expression.
The bitwise operations
(xor)/2 are also supported.