Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

That piece of text, if taken literally and perhaps out of context, means that if we have a * b + c, the Fortran compiler is allowed to add b+c first, and then multiply by a, because there are no parentheses. It's just a question of whether the compiler writers "sees fit" such a thing.

In C, the order of operations is not ambiguous, and is distinct from the evaluation order. In a * b + c, three operands a, b and c have to be evaluated (the variables be reduced to the operand values they hold). This evaluation takes place in an unspecified order (possibly leading to undefined behavior). On these values, however, the arithmetic order of operations is clear: multiplication takes precedence and so is done first.

The evaluation order makes a difference if the expressions a, b and c themselves have side effects.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: