---
title: "Gray code compared with binary numbers"
subject: "Digital Logic"
chapter: 1
key: "semester_3/digital_logic:gray-code-compare-binary"
source: https://www.bctengineer.com/q/semester_3/digital_logic/gray-code-compare-binary
site: BCT Engineering
---

# Gray code compared with binary numbers

Digital Logic · Chapter 1: Introduction

- Asked in: 2076 Asoj, 3 marks
- Video: [Introduction to Gray Code](https://www.youtube.com/watch?v=0dPN4gh0CKI) — Neso Academy
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_3/digital_logic/gray-code-compare-binary
- Whole chapter: https://www.bctengineer.com/md/semester_3/digital_logic/chapter-1

## Question

What is a gray code? Compare with binary numbers.

## Short answer

Gray code is an unweighted code where successive values differ by only one bit. Compared to binary: binary is weighted and used for arithmetic but may change many bits at transitions (e.g., 3→4 changes 3 bits); Gray is unweighted, minimizes transition errors, but is not suitable for arithmetic. Example: (0111)₂ → Gray (0100).

## Answer

**Gray code** is an unweighted, reflected binary code in which **successive numbers differ in only one bit position**. It is used in shaft position encoders, K-maps and ADCs to avoid errors during transitions.

| Decimal | Binary | Gray |
|---|---|---|
| 0 | 000 | 000 |
| 1 | 001 | 001 |
| 2 | 010 | 011 |
| 3 | 011 | 010 |
| 4 | 100 | 110 |
| 5 | 101 | 111 |
| 6 | 110 | 101 |
| 7 | 111 | 100 |

#### Comparison with binary numbers

| Point | Binary | Gray |
|---|---|---|
| Type | Weighted (positional) | Unweighted |
| Change between successive values | Many bits may change (3 → 4: 011 → 100) | Only one bit changes |
| Arithmetic | Easy to add and subtract | Not suitable for arithmetic |
| Error at transitions | False readings possible | Very small error |
| Conversion | — | $G_i = B_{i+1} \oplus B_i$ |

Example: $(0111)_2$ → Gray $(0100)$.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. What is the defining property of Gray code?
   A. Each bit has weights 8, 4, 2, 1
   B. Each decimal digit is coded as digit + 3
   C. Successive numbers differ in exactly one bit
   D. Successive numbers differ in exactly two bits
   Answer: C. Gray code is a unit-distance code: consecutive values differ in only one bit. (Key point: Gray code definition)

2. Between 3 and 4, how many bits change in binary (011 to 100) versus Gray?
   A. Binary 1 bit, Gray 3 bits
   B. Both 1 bit
   C. Both 3 bits
   D. Binary 3 bits, Gray 1 bit
   Answer: D. Gray 010 to 110 changes one bit only. (Key point: Transition change)

3. What is (0111) binary in Gray?
   A. 0100
   B. 0111
   C. 0011
   D. 1000
   Answer: A. Keep 0, 0^1=1, 1^1=0, 1^1=0 gives 0100. (Key point: Gray conversion)

## Related in Digital Logic

- [BCD code and 3-bit binary-to-Gray converter](https://www.bctengineer.com/question.md?key=semester_3%2Fdigital_logic%3Abcd-code-gray-converter) — Digital Logic, chapter 1
- [Gray code and 3-bit binary-to-Gray converter](https://www.bctengineer.com/question.md?key=semester_3%2Fdigital_logic%3Agray-code-binary-gray-converter) — Digital Logic, chapter 1
- [Gray vs binary code, convert (10110)₂ to Gray](https://www.bctengineer.com/question.md?key=semester_3%2Fdigital_logic%3Agray-vs-binary-convert-10110) — Digital Logic, chapter 1
- [Gray code, (11101)Gray to binary, FFH AND CAH](https://www.bctengineer.com/question.md?key=semester_3%2Fdigital_logic%3Agray-to-binary-hex-and) — Digital Logic, chapter 1
- [Gray code with examples](https://www.bctengineer.com/question.md?key=semester_3%2Fdigital_logic%3Agray-code-explain) — Digital Logic, chapter 1, asked 3×
- [Digital signal and Gray code](https://www.bctengineer.com/question.md?key=semester_3%2Fdigital_logic%3Adigital-signal-gray-code) — Digital Logic, chapter 1, asked 2×

## Related in other subjects

- [Complex numbers relational operators](https://www.bctengineer.com/question.md?key=semester_3%2Fobject_oriented_programming%3Acomplex-relational-overload) — Object Oriented Programming, chapter 5
- [8085 ALP: BCD to binary conversion](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3Aalp-8085-bcd-to-binary) — Microprocessor, chapter 2
