User page for:

m8rsh


Liked Puzzles

No likes yet!

Recent Comments

m8rsh 6 months ago

The answer is false.

Consider 2, which is a power of 2. When stored as a 32-bit int, it is encoded as:

0000 0000 0000 0000 0000 0000 0000 0010

n – 1 is

0000 0000 0000 0000 0000 0000 0000 0001

bitwise and

0000 0000 0000 0000 0000 0000 0000 0011

logical negation

0

bitwise negation would give a non-zero answer, but it would give a non-zero answer for any number less than 2^33-1 (all but 32 1s in a row).

(in Power of 2 (Microsoft Interview))