next up previous contents
Next: Cost of Arithmetic Operators Up: More About Operations Previous: Operator Precedence

 

Precedence Example

The following expression,

    x = a+b/5.0-c**d+1*e

is equivalent to

    x = a+b/5.0-(c**d)+1*e

as ** is highest precedence. This is equivalent to

    x = a+(b/5.0)-(c**d)+(1*e)

as / and * are next highest. The remaining operators' precedences are equal, so we evaluate from left to right.

For more information, click here gif

Now try this question gif


next up previous contents
Next: Cost of Arithmetic Operators Up: More About Operations Previous: Operator Precedence

©University of Liverpool, 1997
Wed May 28 23:37:18 BST 1997
Not for commercial use.