**New course!**Every coder should learn

**Generative AI!**

+ 2

# What is Operator precedence

I don’t understand it

8 Answers

+ 6

In math it's what you call the "Order of Operations." Same concept applies since programming is mostly math concepts.
https://en.wikipedia.org/wiki/Order_of_operations
"The order of operations used throughout mathematics, science, technology and many computer programming languages is expressed here:
1. exponents and roots
2. multiplication and division
3. addition and subtraction"
When I was growing up in school, we had PEMDAS, "please excuse my dear aunt sally."
Parenthesis
Exponents
Multiplication
Division
Addition
Subtraction
^That's the order I was taught from what takes highest precedence to least.

+ 2

what is the result of 3*1+1 ?
how about 3*(1+1). ?
result of first one is 4. since first the multiplication comes. then addition.
3*1 =3 , 3+1 =4
result of second is 6. since we declared that the addition must happen first (by putting them in () ). and then multiplication.
1+1=2,. 3*2=6

+ 2

do you. have an example ?
maybe in code...

0

I understand that one but if you add boolean it gets complicated

0

False == (False or True) does it mean false == true ?

0

Thnx

0

as mentioned by @maxwell. parentheses has highest priority. so first, the code inside them will be evaluated then the rest .....

0

Ok I