Operator | Meaning | Example |

+ | addition | `2 is 1 + 1.` |

– | subtraction | `1 is 2 – 1.` |

– | unary minus | Try the query `X is 1, Y is - X.` |

* | multiplication | `4 is 2 * 2.` |

/ | division | `2 is 6 / 3.` |

// | integer division | `1 is 7 // 4.` |

mod | integer remainder | `3 is 7 mod 4.` |

** | exponentiation | `1.21 is 1.1 ** 2.` |

Except in the context of an arithmetic comparison operator, arithmetic
expressions need to be explicitly *evaluated* in Prolog, using
the `is`

built-in predicate.

Mostly one uses these operators in a goal more like this:

X is Y + 2where

`Y`

is a variable already bound to a numeric value,
or perhaps a arithmetic comparison goal like this:
X > Y * ZHere's another example: a rule to tell if a (whole) number is

odd(Num) :- 1 is Num mod 2.Another way to do this one is to use

`=:=`

:
odd(Num) :- Num mod 2 =:= 1.If you wanted to be more cautious, you could first check that

`Num`

is in fact a whole number:
odd(Num) :- integer(Num), 1 is Num mod 2.

As usual in digital computations, with fractional numbers, it is
necessary to be careful with
approximation issues. Thus the final example in the table above,
`1.21 is 1.1 ** 2.`

actually fails when typed into Prolog
as a query. This is because 1.1 ** 2, as represented in computers,
actually comes out to be something like 1.210000000001. See the section
on comparison operators for a solution to
this issue.

Note that SWI Prolog does some apparently strange stuff in the domain of arithmetic (dialogue below done with SWI-Prolog Version 5.6.58):

?- X is [a]. X = 97. ?- X is [a] + [b]. X = 195. ?- X is sqrt(23456). X = 153.154. ?- X is sqrt([23456]). X = 153.154. ?- X is sqrt(123456789). X = 11111.1. ?- X is sqrt([123456789]). X = 13.3791.The ASCII code for

See also comparison operators, built-in functions.