Originally Posted by
VernonDozier
When in doubt, write a program! It's faster and more accurate than research.
ummm....
google seems to quickly turn up a bunch of results for this question, e.g.
http://www.cppreference.com/wiki/operator_precedence
You're right, division/multiplication/modulus all have equal precedence.
Originally Posted by
VernonDozier
... It's one of the reasons I never liked "PEMDAS". If all you remember is the acronym, you always multiply before dividing, which is wrong, and you always add before subtracting, which is also wrong.
I agree, if you multiply before dividing, the answer may be wrong, as in e.g. 2 / 5 * 9
Likewise, if you add before subtracting, e.g. 2 - 5 + 9
However, reversing the above should result in correct answers always: PEDMSA (doesn't really roll off the tongue anymore though)
I'm pretty sure you'll have to use the left-to-right rule for operators where there is >2 operators having equal precedence (i.e. when you add modulus to the mix).