---
title: "Digital signal and Gray code"
subject: "Digital Logic"
chapter: 1
key: "semester_3/digital_logic:digital-signal-gray-code"
source: https://www.bctengineer.com/q/semester_3/digital_logic/digital-signal-gray-code
site: BCT Engineering
---

# Digital signal and Gray code

Digital Logic · Chapter 1: Introduction

- Asked in: 2070 Chaitra, 1+5 marks
- Video: [Lec-9: Binary to Gray Code Conversion & Vice-versa](https://www.youtube.com/watch?v=R7uuIACpdGQ) — Gate Smashers
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_3/digital_logic/digital-signal-gray-code
- Whole chapter: https://www.bctengineer.com/md/semester_3/digital_logic/chapter-1

## Question

Define digital signal and explain Gray code with example.

## Short answer

A digital signal has discrete levels (typically 0 and 1) that change at discrete times. Gray code is an unweighted reflected binary code where consecutive numbers differ by one bit; e.g., binary 1101 → Gray 1011. Used in encoders and K-maps.

## Answer

#### Digital signal
A **digital signal** is a signal that has only a finite number of discrete values (usually two levels, 0 and 1) and changes at discrete instants of time. Example: clock pulses and data in a computer.

#### Gray code
**Gray code** is an unweighted binary code in which **two consecutive numbers differ in only one bit**. It is also called the **reflected binary code**, because the code for $n$ bits is built by writing the $(n-1)$-bit code, reflecting it like a mirror, and prefixing 0 to the top half and 1 to the bottom half.

```text
 1-bit   2-bit    3-bit
  0       00       000
  1       01       001
 ---      11       011
 mirror   10       010
         ----      110
         mirror    111
                   101
                   100
```

| 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 |

**Binary to Gray**: keep the MSB; $G_i = B_{i+1} \oplus B_i$.
Example: $(1101)_2$ → 1, 1⊕1 = 0, 1⊕0 = 1, 0⊕1 = 1 → $(1011)_{Gray}$.

**Gray to binary**: keep the MSB; $B_i = B_{i+1} \oplus G_i$.
Example: $(1011)_{Gray}$ → 1, 1⊕0 = 1, 1⊕1 = 0, 0⊕1 = 1 → $(1101)_2$.

**Features and uses**
- Unweighted, so not used for arithmetic.
- Only one bit changes per step, so it avoids false readings in rotary shaft encoders.
- Used to label K-map rows and columns (00, 01, 11, 10).
- Used in ADCs and low-power counters.

## Check yourself

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

1. What is a digital signal?
   A. One that varies continuously
   B. One with a finite number of discrete values, usually 0 and 1
   C. One that only has positive values
   D. One that is always high
   Answer: B. Digital signals change at discrete instants between discrete levels. (Key point: Digital signal)

2. Why is Gray code called reflected binary code?
   A. Its bits are reversed in order
   B. It repeats the same codes twice
   C. The n-bit code is the (n-1)-bit code mirrored with 0 prefixed to the top half and 1 to the bottom half
   D. It is the inverse of binary
   Answer: C. Reflection builds the sequence step by step. (Key point: Reflected code)

3. What is (1011) Gray in binary?
   A. 1011
   B. 1110
   C. 0100
   D. 1101
   Answer: D. 1; 1^0=1; 1^1=0; 0^1=1. (Key point: Gray to binary)

4. Which is a use of Gray code?
   A. K-map labelling (00, 01, 11, 10)
   B. Decimal arithmetic
   C. Character storage
   D. Weighted addition
   Answer: A. Adjacent cells differ by one bit. (Key point: Uses)

## Close variants set in other exams

- [Digital IC signal levels and Gray code](https://www.bctengineer.com/question.md?key=semester_3%2Fdigital_logic%3Aic-signal-levels-gray-code) — Digital Logic, chapter 1, asked 2×

## Related in Digital Logic

- [Digital/analog signals, Gray and Excess-3 codes](https://www.bctengineer.com/question.md?key=semester_3%2Fdigital_logic%3Adigital-analog-gray-excess3) — 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×
- [3-bit Gray code synchronous counter](https://www.bctengineer.com/question.md?key=semester_3%2Fdigital_logic%3Agray-code-sync-counter-3bit) — Digital Logic, chapter 8, asked 2×
- [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
