I'm trying to get into the book "Hacker's Delight." The first formula in chapter 2 is x & (x -1) and is supposed to "turn off the rightmost 1-bit in a word producing 0 if none
(e.g. 01011000 -> 0101000)." I have no idea why someone would want to do this.
I translated this into python as
bin(0b1011000 and (0b1011000 - 1)) and got
'0b1010111'. Is this correct?
I tried leaving out the "b" designating leading zeros and got this wild result '0b11110110110100110111'.
Am I close to correct?