+1 vote
1.6k views

If X is a binary number which is the power of 2, then the value of X&(X-1) is:

1. 11….11
2. 00…..00
3. 100…..0
4. 000…..1
asked in Others | 1.6k views

let X=2^3=8=1000

then X-1=7=0111

now X&(X-1)=0000

(here & is bitwise AND= If both bits in the compared position of the bit patterns are 1, the bit in the resulting bit pattern is 1, otherwise 0)

so ans is B
selected
just take example:

x=0100

x-1=0011

difference= 0000

again

x=10000

x-1=1111

difference =0000

so option 2

00.......00
0
Question does not say to find difference, it says to find AND

Consider

X = $2^2 = 4$
X = 0100
X-1 = $3$
X-1 = 0011
X & (X-1) = 1111

Consider

X = $2^3 = 8$
X = 1000
X-1 = $7$
X-1 = 0111
X & (X-1) = 1111

So, Ans A) 11...11