|
|
|
|
|
by pbsd
760 days ago
|
|
An alternative, more arithmetic, argument: - x is 2^b*k for some odd k < 2^(n-b) - -x is 2^n - 2^b*k = 2^b*(2^(n-b)-k) - k is odd by definition, and (2^(n-b)-k) + k = 0 (mod 2^(n-b)). This means that the LSB must be 1 in both operands, which results in a carry out, and in the following ith bits we have that the sum is 0 mod 2^i if and only if the ith bits of (2^(n-b)-k) and k are distinct. Thus x & -x = 2^b. |
|
I’m not trying to dunk on you, but I can’t help to note that the denseness of math is too much for an idiot like me.