|Home | Tutorial | Classes | Functions | QSA Workbench | Language | Qt API | QSA Articles | Qt Script for Applications |

[Prev: Assignment Operators] [Home] [Next: String Operators]

#### Arithmetic Operators

These operators are used to perform arithmetic computations on their operands.

##### + operator

`operand1 + operand2`

This operator returns the result of adding the two operands (operand1 and operand2).

See also + string operator.

##### ++ operator

    ++operand; // pre-increment
    operand++; // post-increment

The pre-increment version of this operator increments the operand, and returns the value of the (now incremented) operand.

The post-incremented version of this operator returns the value of the operand, and then increments the operand.

##### - operator

    var result = operand1 - operand2; // subtraction
    operand = -operand;               // unary negation

The subtraction version of this operator returns the result of subtracting its second operand (operand2) from its first operand (operand1).

The unary negation version of this operator returns the result of negating (changing the sign) of its operand.

##### -- operator

    --operand; // pre-decrement
    operand--; // post-decrement

The pre-decrement version of this operator decrements the operand, and returns the value of the (now decremented) operand.

The post-decremented version of this operator returns the value of the operand, and then decrements the operand.

##### * operator

`operand1 * operand2`

This operator returns the result of multiplying the two operands (operand1 and operand2).

##### / operator

`operand1 / operand2`

This operator returns the result of dividing the first operand (operand1) by the second operand (operand2).

Note that division by zero is not an error. The result of division by zero is Infinity.

##### % operator

`operand1 % operand2`

This operator returns the integer remainder (which may be 0) from the division of operand1 by operand2.

[Prev: Assignment Operators] [Home] [Next: String Operators]