Binary to Gray-code conversion Convert the 4-bit binary number 1100₂ to its equivalent Gray code.

Difficulty: Easy

Correct Answer: 1010

Explanation:


Introduction / Context:
Gray code changes only one bit between successive values, reducing errors in position encoders and asynchronous signal transfers. Converting between binary and Gray is a common interview and lab exercise.


Given Data / Assumptions:

  • Binary input: 1100 (b3 b2 b1 b0).
  • We want standard reflected binary Gray code.
  • No arithmetic beyond XOR operations is required.


Concept / Approach:
Rules for binary → Gray: g3 = b3; g2 = b3 XOR b2; g1 = b2 XOR b1; g0 = b1 XOR b0. Apply bitwise XORs from the binary input to produce the Gray output.


Step-by-Step Solution:

1) b3 b2 b1 b0 = 1 1 0 0.2) g3 = b3 = 1.3) g2 = b3 XOR b2 = 1 XOR 1 = 0.4) g1 = b2 XOR b1 = 1 XOR 0 = 1.5) g0 = b1 XOR b0 = 0 XOR 0 = 0.6) Gray result = g3 g2 g1 g0 = 1010.


Verification / Alternative check:
Reverse (Gray → Binary) to confirm: b3 = g3 = 1; b2 = b3 XOR g2 = 1 XOR 0 = 1; b1 = b2 XOR g1 = 1 XOR 1 = 0; b0 = b1 XOR g0 = 0 XOR 0 = 0 → 1100, matching the original.


Why Other Options Are Wrong:

  • 0011, 1001, 1100: do not satisfy Gray-code conversion for 1100₂.


Common Pitfalls:
Using XOR with the wrong neighbor bit or copying the binary number unchanged.


Final Answer:
1010

More Questions from Number Systems and Codes

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion