Jul. 12th, 2010
Note to self:
3 + 8 << 2
is not the same as
3 + (8 << 2)
That's an hour you just spent tracking down a bug based on a mistake you've made several times before.
Yes, I know, brackets. Normally I'm assiduous about brackets. But for short lines like, say,
3 + 8*2
I actually think they detract from readability.
I'm sure there are sound reasons why shift has precedence over addition in C, but I find it counter-intuitive in the extreme.
Maybe a nice dose of online mockery will help me remember in the future :(
Note to non-geeks:
Don't worry, not much to see here. I made a school-boy error.
3 + 8 << 2
is not the same as
3 + (8 << 2)
That's an hour you just spent tracking down a bug based on a mistake you've made several times before.
Yes, I know, brackets. Normally I'm assiduous about brackets. But for short lines like, say,
3 + 8*2
I actually think they detract from readability.
I'm sure there are sound reasons why shift has precedence over addition in C, but I find it counter-intuitive in the extreme.
Maybe a nice dose of online mockery will help me remember in the future :(
Note to non-geeks:
Don't worry, not much to see here. I made a school-boy error.