# DiGrande.it

Blind, Braille and Embossing Technologies

This site uses cookies to personalize content and ads, provide social media features and analyze links. By closing this banner or continuing to browse, you consent to their use.

# The arithmetic operators

Arithmetic operators are special symbols that perform basic arithmetic operations between one or more operands. For example:

- x1 = 50

- x2 = x1+20

The following arithmetic operators can be used:

- - (less) Algebraic subtraction

- * (asterisk) Algebraic multiplication

- / (slash) Algebraic Division

- % (per hundred) Module, rest of the algebraic division

These operators are of the binary type because they need two operands to be applied. For example:

- Dot(10+5,70+20)

- x = 50-30

- l = 5*6

- Dot(x+l/6,6*l)

Operators who need only one operand are called unari. Two single operators are also available and they are

- + (Plus) Always makes the operand always with a positive sign (absolute value)

- - (less) Change the sign of the operand (arithmetic negation)

For example:

- x = 50

- z = -x

y = +z/2

Variable z will contain the value -50 and variable y will contain the value +25.

All arithmetic operators can be used in the instantiation of a variable, in the parameters of an instruction or in relational expressions. All expressions are evaluated from left to right, without respecting the formal precedence between operators. In other words, all operators operate at the same level. Round brackets can be used to give priority to operations. The parentheses work on arithmetic, logical or relational expressions. The parentheses can be nested and the most internal expressions are evaluated first. For an expression to be correct, the number of round brackets on the left must be equal to that of round brackets on the right, and properly nested. For example:

- x = 14+8/2

The variable "x" will contain the value 11.

- x = 14+(8/2)

The variable "x" will contain the value 18.