# Arithmetic

`a + b`

Type of `a`

Type of `b`

Type of `a + b`

WITH TYPE PROMOTION

Fails with

`"proto.alpha.tez.addition_overflow"`

`a + b`

value typed `tez`

exceeds `9223372036854775807utz`

`a - b`

Subtracts numbers.

Type of `a`

Type of `b`

Type of `a - b`

WITH TYPE PROMOTION

Fails with

`"INVALID_NEGATIVE_TEZ"`

`a - b`

value typed `tez`

is negative.`- a`

`a`

.Fails with

does not fail

`a * b`

Multiplies two numbers

Type of `a`

Type of `b`

Type of `a * b`

WITH TYPE PROMOTION

Fails with

does not fail

`a / b`

Divides two numbers as a rational.

Fails with

does not fail

`a div b`

Returns the euclidean quotient of two `a`

divided by `b`

; `a div b`

is equivalent to:

`match a /% b with`

| some(q,r) -> q

| none -> fail("DIV_BY_ZERO")

end

Fails with

`"DIV_BY_ZERO"`

`b`

is equal to 0`a % b`

Returns the euclidean remainder of `a`

divided by `b`

(modulus); `a % b`

is equivalent to:

`match a /% b with`

| some(q,r) -> r

| none -> fail("DIV_BY_ZERO")

end

Fails with

`"DIV_BY_ZERO"`

`b`

is equal to 0`a /% b`

`a`

by `b`

; returns an option of quotient and remainder:`some(q, r)`

, when`b`

is different from 0,`q`

being the quotient and`r`

the remainder`none`

, when`b`

is equal to 0

Fails with

does not fail

`a <<| b`

`a`

to the left by the number of positions specified by `b`

. Simultaneously, the empty spaces created by the bits shifted to the left are then filled with zeroes. It is a fast way to multiply by a power of 2.Fails with

`"script_overflow"`

`b`

is greater than `256`

`a |>> b`

`a`

to the right by the number of positions specified by `b`

. It is a fast way to divide by a power of 2.Fails with

`"script_overflow"`

`b`

is greater than `256`

`a and b`

`true`

if`a`

and`b`

are`true`

`false`

otherwise.

Fails with

does not fail

`a or b`

`true`

if`a`

or`b`

is`true`

`false`

otherwise

Fails with

does not fail

`a xor b`

`true`

if`a`

and`b`

are different`false`

otherwise

Fails with

does not fail

`not a`

`a = b`

Type of `a`

Type of `b`

Type of `a = b`

WITH TYPE PROMOTION

Fails with

does not fail

`a <> b`

`not (a = b)`

.Type of `a`

Type of `b`

Type of `a <> b`

WITH TYPE PROMOTION

Fails with

does not fail

`a < b`

Type of `a`

Type of `b`

Type of `a < b`

WITH TYPE PROMOTION

Fails with

does not fail

`a <= b`

Type of `a`

Type of `b`

Type of `a <= b`

WITH TYPE PROMOTION

Fails with

does not fail

`a > b`

Type of `a`

Type of `b`

Type of `a > b`

WITH TYPE PROMOTION

Fails with

does not fail

`a >= b`

Type of `a`

Type of `b`

Type of `a >= b`

WITH TYPE PROMOTION

Fails with

does not fail

`a <=> b`

`-1`

when`a < b`

`1`

when`a > b`

`0`

when`a = b`

Type of `a`

Type of `b`

Type of `a <=> b`

WITH TYPE PROMOTION

Fails with

does not fail

`a < b < c`

Double inequality operators are syntactic shortcuts for logical conjonction of two comparisons:

Equivalence

`a < b < c`

`a < b and b < c`

`a <= b < c`

`a ≤ b and b < c`

`a < b <= c`

`a < b and b ≤ c`

`a <= b <= c`

`a ≤ b and b ≤ c`