Arithmetic Expressions

All the possible arithmetic expressions are shown in the following table. Each arithmetic operation has one or two arguments—these arguments are shown in the table as Integer or Number (Number means the argument can be an integer or a float).

Table 3. Arithmetic expressions

Op

Description

Arg. Type

Priority

+ X

+ X

Number

1

- X

- X

Number

1

X * Y

X * Y

Number

2

X / Y

X / Y (floating-point division)

Number

2

bnot X

Bitwise not of X

Integer

2

X div Y

Integer division of X and Y

Integer

2

X rem Y

Integer remainder of X divided by Y

Integer

2

X band Y

Bitwise and of X and Y

Integer

2

X + Y

X + Y

Number

3

X - Y

X - Y

Number

3

X bor Y

Bitwise or of X and Y

Integer

3

X bxor Y

Bitwise xor of X and Y

Integer

3

X bsl N

Arithmetic bitshift left of X by N bits

Integer

3

X bsr N

Arithmetic ...

Get Programming Erlang, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.