in Digital Logic recategorized
575 views
1 vote
1 vote

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

  1. $11\dots11$
  2. $00\dots00$
  3. $100\dots0$
  4. $000\dots1$
in Digital Logic recategorized
575 views

5 Answers

4 votes
4 votes
Best answer
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 by
1 vote
1 vote

X & X-1 is a bitwise operation which is used to check whether a number is power of 2 or not.

For ex. X= 8(1000), X= 7(0111) 

X & X-1 = 0000.

Let X= 16(10000) , X= 15(01111)

X & X-1 = 00000.

The Expression X & X-1 will always give 0 when X is power of 2.

Hence option b) is correct.

1 vote
1 vote
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)

1 comment

ans is b

bnary numbers are as power of 2 have 1 in representation only at one place and odd nujmber have one at other place and their anding results in zero.
0
0
0 votes
0 votes
just take example:

x=0100

x-1=0011

difference= 0000

again

x=10000

x-1=1111

difference =0000

 

so option 2

00.......00

1 comment

Question does not say to find difference, it says to find AND
0
0
Answer:

Related questions