JSONiq supports the basic four operations, integer division and modulo.

Multiplicative operations have precedence over additive operations. Parentheses can override it.

1 * ( 2 + 3 ) + 7 idiv 2 - (-8) mod 2

Dates, times and durations are also supported in a natural way.

date("2013-05-01") - date("2013-04-02")

If any of the operands is a sequence of more than one item, an error is raised.

(1, 2) + 3

If any of the operands is not a number, a date, a time or a duration, an error is raised.

1 + null

If one of the operands evaluates to the empty sequence, then the operation results in the empty sequence.

Do not worry if the two operands do not have the same number type, JSONiq will do the adequate conversions.

() + 2