On Friday, 18 January 2013 at 10:40:50 UTC, Mehrdad wrote:
On Friday, 18 January 2013 at 10:30:33 UTC, deadalnix wrote:
If you believe you know operator precedence, you are probably wrong. And even if you are right, most other programmer don't.


They're not /that/ bad...

+ - * / %  are like in math
<< >> are harder, but all you need is to recall that cout << x + 2;
           works as written
| & are just like in math (or is addition, and is multiplication)
^          is in between | and &
|| && are just like in math (or is addition, and is multiplication)


that takes care of helping you remember all the 'sane' cases so you don't need parentheses.

If you're doing something obscure like x = x | y || w & z && 5 | 6 || 7;
then yeah, you should seriously put parentheses.

Reply via email to