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.
no subject
Date: 2010-07-12 03:44 pm (UTC)no subject
Date: 2010-07-13 10:44 am (UTC)(I think this error was indeed introduced because I changed a *7 to a *8, and instinctively altered it to a <<3. Which I'm quite sure our compiler is smart enough to do for me, anyway.)
no subject
Date: 2010-07-13 10:49 am (UTC)no subject
Date: 2010-07-13 11:02 am (UTC)Interesting. I'd never really thought about the choice of syntax indicating subtle meaning to future readers. So much more sophisticated than comments ;)