Robotics C++ Physics II AP Physics B Electronics Java Astronomy Other Courses Summer Session  

Precedence of Math Operators

 

Parenthese take priority over all of the math operators

 

 A good rule is to use ( ) wisely to force the correct sequence of operations   ( ) is  - highest precedence

Operators with highest precedence are evaluated first

When operators have equal precedence, they are evaluated left to right

Precedence of the remaining operators is given in the following table, highest precedence at the top

 

Operator

Operation

Order of Evaluation (Precedence)

  ( )

  Grouping

  This operator has the highest precedence

 

Operator

Operation

Order of Evaluation (Precedence)

*

Multiplication

These 3 operators have equal precedence.

If there are several of this type operator, they are evaluated left to right

 

 

/

Division

%

Remainder

 

Operator

Operation

Order of Evaluation (Precedence)

+

Addition

These 2 operators have equal precedence.

If there are several of this type operator, they are evaluated left to right

 

-

Subtraction