The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+1 vote
1.2k 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 by Veteran (342k points) | 1.2k views

3 Answers

+1 vote
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
answered by (107 points)
selected by
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
answered by Active (3.9k points)
0
Question does not say to find difference, it says to find AND
0 votes

Answer A)

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

answered by Active (4.8k points)


Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

35,518 questions
42,792 answers
121,605 comments
42,162 users