---
title: "Digital/analog signals, Gray and Excess-3 codes"
subject: "Digital Logic"
chapter: 1
key: "semester_3/digital_logic:digital-analog-gray-excess3"
source: https://www.bctengineer.com/q/semester_3/digital_logic/digital-analog-gray-excess3
site: BCT Engineering
---

# Digital/analog signals, Gray and Excess-3 codes

Digital Logic · Chapter 1: Introduction

- Asked in: 2079 Baisakh, 6 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-analog-gray-excess3
- Whole chapter: https://www.bctengineer.com/md/semester_3/digital_logic/chapter-1

## Question

Define Digital and analog Signal, Explain Gray and Excess 3 code with example.

## Short answer

An analog signal is continuous in time and amplitude; a digital signal has discrete values (usually 0,1). Gray code is unweighted, successive values differ by one bit (e.g., binary 1011 → Gray 1110). Excess‑3 code adds 3 to each decimal digit and encodes it in 4 bits; it is self‑complementing (e.g., 27 → 0101 1010).

## Answer

#### Analog signal
An **analog signal** is a continuous signal that can take any value within a range at every instant of time, e.g. a sine wave, voice from a microphone, or temperature from a thermocouple.

#### Digital signal
A **digital signal** takes only a finite number of discrete values (usually two: 0 and 1) and changes only at discrete instants, e.g. the clock or data in a computer.

```text
 Analog :   /\    /\        Digital:  _   __    _
           /  \  /  \                | | |  |  | |
          /    \/    \             __| |_|  |__| |__
```

#### Gray code
Gray code is an unweighted, reflected binary code in which **consecutive numbers differ in only one bit**.

| 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 MSB, then $G_i = B_{i+1} \oplus B_i$.
Example: $(1011)_2$ → 1, 1⊕0 = 1, 0⊕1 = 1, 1⊕1 = 0 → $(1110)_{Gray}$.
Used in shaft encoders and K-maps.

#### Excess-3 code
Excess-3 is an unweighted BCD code where each decimal digit is coded as the binary of **digit + 3**.

| Decimal | 0 | 1 | 2 | 5 | 9 |
|---|---|---|---|---|---|
| XS-3 | 0011 | 0100 | 0101 | 1000 | 1100 |

Example: $(27)_{10}$ → 2+3 = 5 → 0101, 7+3 = 10 → 1010 → $(0101\ 1010)_{XS-3}$.
It is **self-complementing**: inverting the bits gives the 9's complement (e.g. 2 = 0101 → 1010 = 7 = 9 − 2).

## Check yourself

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

1. How does a digital signal differ from an analog one?
   A. It is continuous and takes any value
   B. It has only positive values
   C. It takes only a finite set of discrete values; analog varies continuously
   D. It cannot represent data
   Answer: C. Digital has discrete levels (usually 0 and 1). (Key point: Analog vs digital)

2. 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 two bits
   D. Successive numbers differ in exactly one bit
   Answer: D. Gray code is a unit-distance code: consecutive values differ in only one bit. (Key point: Gray code definition)

3. What is 1011 binary in Gray code?
   A. 1110
   B. 1101
   C. 1011
   D. 0101
   Answer: A. Keep 1, then 1^0=1, 0^1=1, 1^1=0. (Key point: Binary to Gray example)

4. What is (27) decimal in Excess-3?
   A. 0010 0111
   B. 0101 1010
   C. 0101 0111
   D. 0100 1001
   Answer: B. 2+3=5 gives 0101; 7+3=10 gives 1010. (Key point: XS-3 of 27)

## Related in Digital Logic

- [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×
- [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×
- [Advantages of digital over analog signals](https://www.bctengineer.com/question.md?key=semester_3%2Fdigital_logic%3Adigital-over-analog-advantages) — Digital Logic, chapter 1, asked 5×
- [Analog/digital signals and digital advantages](https://www.bctengineer.com/question.md?key=semester_3%2Fdigital_logic%3Adefine-analog-digital-advantages) — Digital Logic, chapter 1, asked 5×
- [Difference between analog and digital signals](https://www.bctengineer.com/question.md?key=semester_3%2Fdigital_logic%3Aanalog-vs-digital-signals) — Digital Logic, chapter 1
- [Analog vs digital signal; convert A2.64H](https://www.bctengineer.com/question.md?key=semester_3%2Fdigital_logic%3Aanalog-digital-convert-a264h) — Digital Logic, chapter 1

## Related in other subjects

- [Define analog and digital signals](https://www.bctengineer.com/question.md?key=semester_5%2Fdata_communication%3Aanalog-digital-signal-define) — Data Communication, chapter 1
- [PCM and analog-to-digital conversion](https://www.bctengineer.com/question.md?key=semester_5%2Fdata_communication%3Apcm-working) — Data Communication, chapter 5, asked 4×
- [Why digitize analog signals](https://www.bctengineer.com/question.md?key=semester_5%2Finstrumentation_ii%3Awhy-digitize) — Instrumentation II, chapter 4, asked 2×
- [Advantages of digital over analog transmission](https://www.bctengineer.com/question.md?key=semester_5%2Finstrumentation_ii%3Adigital-vs-analog-transmission-adv) — Instrumentation II, chapter 5
