All these operators evaluate and compare the arithmetic values of their arguments, these operators can be used like the is/2 operator to force the Prolog interpreter to perform arithmetic evaluation. However unlike the is/2 operator must the left operand not be an empty variable.
| Operator | Name |
| =:= | arithmetic equal |
| =\= | arithmetic not equal |
| > | arithmetic greater than |
| >= | arithmetic greater than or equal |
| < | arithmetic smaller than |
| =< | arithmetic smaller than or equal |
Compare if both arguments have the same arithmetic value.
| Examples | |
| :- X=5, X =:= 2 + 3. | succeeds, X= 2 |
| :- X=4, X =:= 2 + 3. | no |
Compare if both arguments have different arithmetic values.
| Examples | |
| :- X=5, X =\= 2 + 3. | no |
| :- X=4, X =\= 2 + 3. | succeeds, X=4 |
Compare if the value of the left argument is larger than the value of the right argument.
| Examples | |
| :- X=5, X > 2 + 3. | no |
| :- X=6, X > 2 + 3. | succeeds, X=6 |
Compare if the value of the left argument is larger than or equal to the value of the right argument.
| Examples | |
| :- X=5, X >= 2 + 3. | succeeds, X=5 |
| :- X=4, X >= 2 + 3. | no |
Compare if the value of the left argument is smaller than the value of the right argument.
| Examples | |
| :- X=5, X < 2 + 3. | no |
| :- X=2.7, X < 2 + 3. | succeeds, X=2.7 |
Compare if the value of the left argument is smaller than or equal to the value of the right argument.
| Examples | |
| :- X=5, X =< 2 + 3. | succeeds, X=5 |
| :- X=4, X =< 2 + 3. | succeeds, X=4 |
see also: bit operators \= /2 = /2 is/2 unify_with_occurs_check/2 arithmetic evaluation