next up previous
Next: Exercises Up: Unit 04 Previous: Predicates

Precedence between operators of different types

When we have to evaluate complex expressions in which appear operators of different types, we have to take into account the various precedences:

  1. logical negation (!) - high precedence
  2. arithmetic operators
  3. relational operators
  4. logical conjunction (&&) and logical disjunction (||) - low precedence

Example:

  a+2  ==  3*b   ||   !trovato  &&  c <  a/3       is equivalent to
((a+2) == (3*b)) || ((!trovato) && (c < (a/3)))


next up previous
Next: Exercises Up: Unit 04 Previous: Predicates