GATE Computer ScienceHardGATE CS (PYQ pattern)

The double-dabble algorithm converts the 8-bit binary number 10110111 (183) to BCD. Before each of the 8 shifts, every BCD digit that is 5 or more has 3 added to it. How many such 'add 3' corrections (counted per digit) occur in total?

  1. A. 2
  2. B. 3
  3. C. 4
  4. D. 5

Correct answer: B. 3

Trace the algorithm: before each shift, add 3 to every BCD digit that is at least 5. Over the 8 shifts this happens 3 times in total, ending with 0001 1000 0011 = 183.

More Digital Logic questions

Exams that ask this topic