Submitted by TheManNamedPeterPan t3_z8c5vf in explainlikeimfive
Kalirren t1_iyc8k40 wrote
The real reason why we do this is so that we can write DISTRIBUTION neatly.
(4+5)*6 = 4*6 + 5*6
See how I didn't have to write the right side of that with any parentheses at all?
If we had pure left-to-right order of operations, I'd have had to write
(4+5)*6 = (4*6) + (5*6)
which is much uglier.
Note also that * distributes over +, but + doesn't distribute over *:
4+(5*6) != (4+5) * (4+6)
So there's no advantage of less parentheses in assuming that + should be the first operation you perform.
Similarly, exponentiation distributes over multiplication. That's why the usual order of operations is PEMA:
P (exceptions before general rules)
E (^ distributes over *)
M (* distributes over +)
A
Viewing a single comment thread. View all comments