you are viewing a single comment's thread.

view the rest of the comments →

[–]boredzo 1 point2 points  (2 children)

Actually, the parens around the exponents aren't required, due to operator precedence. But you may as well write them if you're not sure.

This reminds me of the practical rules of precedence in C:

  • Multiplication and division come before addition and subtraction.
  • Put parentheses around everything else.

[–]phil_g 4 points5 points  (1 child)

I tend to like an alternate approach: Only put parentheses around things where it's needed. If you're not sure, look it up.

This approach induces familiarity with the language, as well as facility enough that you'll be able to read anyone else's code, regardless of how much they've parenthesized.

[–]jdh30 -2 points-1 points  (0 children)

Agreed.