=40/2*16

lezawang

Well-known Member
Joined
Mar 27, 2016
Messages
1,805
Office Version
  1. 2016
Platform
  1. Windows
Hi
The result of above formula is 320? Why division has higher priority than multiplication? I thought the order of Operations is
PEMDAS

So M before D?
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Why division has higher priority than multiplication?
I believe that multiplication and division have the same priority, so it goes from left to right.
I always recommend using parenthesis where necessary to make sure it calculates exactly they way you want.
 
Upvote 0
In Pemdas... M and D have the same rank since they technically are the same thing and the same goes for A and S


it is really... P -> E -> MD -> AS

3-2 can be rewritten -2+3 ... so adding and subtracting is interchangeable as is multiplication and division

1*2 = 1 / (1 / 2) (multiply inverse)

Excel will honor pemdas ... so with adding/subtracting and multiplication/division ...it calculates from left to right
 
Last edited:
Upvote 0
I believe that multiplication and division have the same priority, so it goes from left to right.
I always recommend using parenthesis where necessary to make sure it calculates exactly they way you want.

In my opinion, if you have a sense of order of operations, then the additional parentheses hurts readability. With coworkers, in order to read their functions i have to go through and delete the extra parentheses they throw in. I don't know if that is just me though.
 
Upvote 0
In my opinion, if you have a sense of order of operations, then the additional parentheses hurts readability. With coworkers, in order to read their functions i have to go through and delete the extra parentheses they throw in. I don't know if that is just me though.

I second that emotion. That's the first thing I do, as well. One the worst examples that I've seen is a so-called MVP suggesting an expression of the form
((1.23)*((56.7)/(890))). I kid you not: parentheses around constants. Wh-a-a-t?!

However, I do recommend unneeded parentheses in expressions like (40/2)*16 because the intent of 40/2*16 is unclear. Actually, I recommend that it be changed to 16*40/2 unless the programmer needs to pay attention to limits of binary floating-point arithmetic, or he is trying to utilize order-sensitive anomalies of binary floating-point arithmetic -- never a good idea except for educational purposes, IMHO.
 
Last edited:
Upvote 0
unless the programmer needs to pay attention to limits of binary floating-point arithmetic, or he is trying to utilize order-sensitive anomalies of binary floating-point arithmetic

Just what I was thinking LOL
 
Upvote 0
Errata....
However, I do recommend unneeded parentheses in expressions like (40/2)*16 because the intent of 40/2*16 is unclear. Actually, I recommend that it be changed to 16*40/2

Oops! I just read the OP more closely, and I see that Leza intended 40/(2*16). Obviously, parentheses are required in that case; nothing "extra" about them. Or change the formula to 40/2/16.
 
Upvote 0
Upvote 0
In my opinion, if you have a sense of order of operations, then the additional parentheses hurts readability.
I respectfully disagree. If there is one thing that this thread shows, it is that most people do NOT understand the order of operations. So removing any confusion is not necessarily a bad thing. Does it hurt performance? I think not, so to make a formula one or two characters shorter really isn't any real advantage.

That being said, you can go overboard. The formula JoeU posted is a good example of that. Most of those parentheses add no value, and one could actually argue they can lead to more confusion.

One of my pet peeves is if you use Access, and create a query with multiple criteria, and then view the query in SQL View, Access goes a little crazy like this with the number of parentheses in the WHERE clause.

I guess it comes back to the old adage, "everything in moderation...".
 
Upvote 0
I see your point but I suppose it is personal preference. If you know PEMDAS and are familiar with Excel then at that point I think any extra parentheses adds clutter.

16 * (40 / 2) should be written as 40/2*16

why make your brain have to organize what goes first when you can execute like reading a book... with parentheses is just like putting Go To's in code... it changes the natural flow of the code and requires you to read much more closely and pay attention to what needs to be processed first. IMO it requires more thinking. But just how I see it, I think it goes to how people think.
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,159
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top