Arithmetic Operators



index
Disabled back button Next Section
printable version

Section 1: Overview

Table of Arithmetic Operators.

Examples:

Section 2: Assignment Operators

An assignment operator assigns the value of its right operand to its left operand. The basic assignment operator is equal (=), which assigns the value of its right operand to its left operand. That is, x = y assigns the value of y to x.

Think of the assignment operator as a left arrow: ←

The other assignment operators are shorthand for standard operations, as shown in the following table.

Table of Assignment Operators
Section 3: Operator Precedence

If multiple arithmetic operators are included in a single equation, the operations are performed in a specific order:

Table of Operator Precedence

Example:

Example of Operator Precedence

Parentheses can be used to clarify the precedence of operators in an expression, or even alter the precedence. Parentheses have a higher precedence than any operator.

Section 4: Expression Type

Expressions have both a type and a value.

Example of Expression Types

For addition, subtraction, or multiplication, if either operand is real, the result is real.

For real division (/), the result is real regardless of the types of the operands.

More on type conversions in our type conversion notes.

Section 5: Resources