You're replying to a comment by John Doe.

John Doe Permalink
July 01, 2009, 15:06

Sorry to be a party crusher, but you've got a mistake (at least one, I stopped reading.)

Bit Hack #6. Turn off the rightmost 1-bit.

y = x & (x-1)

Plain wrong. Any X ending with xxx10, when ANDed with (x-1), which obviously ends with xxx01, gives xxx00, ie. a number whose LAST TWO BITS ARE 0.

2d & 1d = 0
10d (0xA) & 9d (0x9) = 8.


Reply To This Comment

(why do I need your e-mail?)

(Your twitter handle, if you have one.)

Type the word "coding_143": (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.