Question 3Asked in UGC NET Computer Science, June 2017 (Paper II & III, Selected Questions)

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

  1. A11.......11
  2. B00.......00
  3. C100......0
  4. D000.......1
Show answerHide answer

Correct answer: (B) 00.......00

Explanation

Let x = 2³ = 8 = 1000; then x – 1 = 7 = 0111. Now x & (x – 1) = 0000 (& is bitwise AND: a result bit is 1 only if both compared bits are 1, otherwise 0). So for any power of 2 the result is all zeros.

From UGC NET Computer Science PYQ, June 2017 (Paper II & III, Selected Questions)

This is question 3 of UGC NET Computer Science PYQ, June 2017 (Paper II & III, Selected Questions). See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.