---
title: "Gray vs binary code, convert (10110)₂ to Gray"
subject: "Digital Logic"
chapter: 1
key: "semester_3/digital_logic:gray-vs-binary-convert-10110"
source: https://www.bctengineer.com/q/semester_3/digital_logic/gray-vs-binary-convert-10110
site: BCT Engineering
---

# Gray vs binary code, convert (10110)₂ to Gray

Digital Logic · Chapter 1: Introduction

- Asked in: 2079 Bhadra, 2+2+2 marks
- Video: [Gray code || Convert Binary to Gray code and vice-versa || Digital logic design | DLD | STLD | CO](https://www.youtube.com/watch?v=lubafVM2ONA) — Sudhakar Atchala
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_3/digital_logic/gray-vs-binary-convert-10110
- Whole chapter: https://www.bctengineer.com/md/semester_3/digital_logic/chapter-1

## Question

What is a Gray code? How is it different than binary code? Convert (10110)₂ to Gray code?

## Short answer

Gray code is unweighted; consecutive numbers differ in exactly one bit, unlike weighted binary where many bits can change. To convert (10110)₂ to Gray: keep MSB 1, then G₃=1⊕0=1, G₂=0⊕1=1, G₁=1⊕1=0, G₀=1⊕0=1 → (11101)Gray.

## Answer

#### Gray code
**Gray code** is an unweighted binary code in which **two successive values differ in only one bit**. It is also called the reflected binary code. Example sequence: 000, 001, 011, 010, 110, 111, 101, 100.

#### Difference from binary code

| Point | Binary code | Gray code |
|---|---|---|
| Weights | Weighted (1, 2, 4, 8…) | Unweighted |
| Bit change between successive numbers | One or more (011 → 100 changes 3 bits) | Exactly one |
| Arithmetic | Easy | Not suitable |
| Switching errors | Possible at transitions | Minimal |
| Uses | Computation, storage | Encoders, K-maps, ADCs |

#### Convert $(10110)_2$ to Gray
Keep the MSB; each following Gray bit is the XOR of two adjacent binary bits.

```text
 Binary: 1   0   1   1   0
         | \ | \ | \ | \ |
 Gray  : 1   1   1   0   1
```

- $G_4 = B_4 = 1$
- $G_3 = 1 \oplus 0 = 1$
- $G_2 = 0 \oplus 1 = 1$
- $G_1 = 1 \oplus 1 = 0$
- $G_0 = 1 \oplus 0 = 1$

**Answer: $(10110)_2 = (11101)_{Gray}$**

## 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. How does Gray code differ from binary in weighting?
   A. Both are unweighted
   B. Gray is weighted; binary is not
   C. Both have weights 8-4-2-1
   D. Gray is unweighted; binary is weighted
   Answer: D. Binary bits have positional weights; Gray bits do not. (Key point: Weights)

3. What is (10110) binary in Gray code?
   A. 11101
   B. 10110
   C. 11011
   D. 01101
   Answer: A. Keep 1, then 1^0=1, 0^1=1, 1^1=0, 1^0=1. (Key point: Gray conversion)

4. Why is Gray code not used for arithmetic?
   A. It needs more bits
   B. It is unweighted, so arithmetic is not suitable
   C. It has invalid codes
   D. Its bits change randomly
   Answer: B. Arithmetic needs weighted positions, which Gray lacks. (Key point: Arithmetic)

## Related in Digital Logic

- [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
- [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 code compared with binary numbers](https://www.bctengineer.com/question.md?key=semester_3%2Fdigital_logic%3Agray-code-compare-binary) — Digital Logic, chapter 1
- [Convert (110111)gray to binary](https://www.bctengineer.com/question.md?key=semester_3%2Fdigital_logic%3Aconvert-gray-110111-binary) — Digital Logic, chapter 1
- [Convert (01010111)gray to binary](https://www.bctengineer.com/question.md?key=semester_3%2Fdigital_logic%3Aconvert-gray-01010111-binary) — Digital Logic, chapter 1

## Related in other subjects

- [5-bit R-2R DAC output for 10110](https://www.bctengineer.com/question.md?key=semester_4%2Fadvanced_electronics%3Ar2r-5bit-10110) — Advanced Electronics, chapter 3
- [Convolutional vs block codes; (7,4) cyclic code for 1011](https://www.bctengineer.com/question.md?key=semester_6%2Fcommunication_systems%3Aconv-vs-block-cyclic-7-4-1011) — Communication Systems, chapter 8, asked 2×
- [Convolutional vs block coder; (7,4) cyclic code for 1010](https://www.bctengineer.com/question.md?key=semester_6%2Fcommunication_systems%3Aconv-vs-block-cyclic-7-4-1010) — Communication Systems, chapter 8, asked 2×
