Arithmetic Operators

Expressions with binary operators group left-to-right. The usual arithmetic conversions are performed.

arithmetic-expression:
        expression + expression
        expression - expression
        expression * expression
        expression / expression
        expression % expression
        - expression

The result of the + operator is the sum of the operands.

The result of the - operator is the difference of the operands.

The binary * operator indicates multiplication.

The binary / operator indicates division.

The binary % operator yields the remainder from the division of the first expression by the second. The two operands must be of integral type (i.e. integers or characters).

The unary - operator is the negative of its operand.

All arithmetic operators are strict, i.e. they return @ if either operand is @.

If both operands of an arithmetic expression are of integral type, the result is always an integer. If any operand is a floating point, the result is a floating point (except for the % operator which takes integral operands only).


[FORWARD] [HOME] [UP] [HELP]