# Expressions

Expressions are used to compute values by applying operators to variables, constants and literal values. The operators for the predefined types include:

integer ops | `+, -, *, /, %` (modulus) |
e.g. `(13+4)/5` is `3` |

real ops | `+, -, *, /` |
e.g. `(13.0+4.0)/5.0` is `3.4` |

relational ops | `==, !=, >=, <=, >, <` |
e.g. `(6+2)<9` is `true` |

logical ops | `&&` (and), `||` (or), `!` (not) |
e.g. `(6>8) || (3<4)` is `true` |

bit-shift ops | `>>, <<` |
e.g. `2<<10` is `2048` |

Precedence order:

- 1.
`!`

,`not`

(logical not)- 2.
`*, /, %`

- 3.
`+, -`

- 4.
`>>, <<`

- 5.
`<, <=, >, >=`

- 6.
`==, !=`

- 7.
`&&`

,`and`

(logical and)- 8.
`||`

,`or`

(logical or)

Increment and decrement operators (see section 8 on assignment statements):

`count++`

is equivalent to`count = count + 1;`

`count--`

is equivalent to`count = count - 1;`

Operators can be defined for user types. See the use of `<<`

and
`>>`

in section 11, and the `--`

member function in
the example class in section 18.