# Arithmetic

The Relevance language includes the typical binary mathematical functions, including addition, subtraction, multiplication, division and modulo.

``````Q: 21 mod 5
A: 1``````

Returns the integer corresponding to 21 modulo 5.

``````Q: 36*month/2
A: 1 years, 6 months``````

Multiplies and divides months resulting in a ‘month and year’ type.

``````Q: 2+3
A: 5``````

Adds integers together to produce a sum.

``````Q: current month + 2*month
A: November``````

Adds two months to the current month (in this case, September).

``````Q: december - current month
A: 3 months``````

Subtracts the current month (1-12) from December (12) to produce a ‘number of months’ type.

A few operators in the language are unary (requiring only one argument), such as negation:

``````Q: -(3*5)
A: -15``````

As expected, this minus sign negates its argument (the product in parentheses).

There is another "arithmetic" symbol, the ampersand (&). This is the concatenation operator that joins strings:

``````Q: "now" & "then"
A: nowthen``````

It’s also used to create time ranges:

``````Q: now & day
A: Sat, 21 Oct 2006 21:55:28 -0400 to Sun, 22 Oct 2006 21:55:28 -0400``````