---
title: "Gray code, (11101)Gray to binary, FFH AND CAH"
subject: "Digital Logic"
chapter: 1
key: "semester_3/digital_logic:gray-to-binary-hex-and"
source: https://www.bctengineer.com/q/semester_3/digital_logic/gray-to-binary-hex-and
site: BCT Engineering
---

# Gray code, (11101)Gray to binary, FFH AND CAH

Digital Logic · Chapter 1: Introduction

- Asked in: 2076 Asoj
- Video: [How To Convert Gray Code to Binary and Binary to Gray Code](https://www.youtube.com/watch?v=cbmh1DPPQyI) — The Organic Chemistry Tutor
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_3/digital_logic/gray-to-binary-hex-and
- Whole chapter: https://www.bctengineer.com/md/semester_3/digital_logic/chapter-1

## Question

Define Gray Code and convert (11101)Gray code to binary. When (FF)H is ANDed with (CA)H what will be the resulting number.

## Short answer

Gray code is an unweighted code where successive values differ in only one bit. (11101)Gray = (10110) binary (22 decimal). Bitwise AND of (FF)H and (CA)H is (CA)H (11001010, decimal 202).

## Answer

#### Gray code
**Gray code** is an unweighted, cyclic (reflected binary) code in which two successive numbers differ in **only one bit**. Example: 0 → 000, 1 → 001, 2 → 011, 3 → 010, 4 → 110. Because only one bit changes at a time, it avoids false outputs during transitions and is used in shaft encoders and K-map labelling.

#### (11101) Gray to binary
Rule: $B_{MSB} = G_{MSB}$, then $B_i = B_{i+1} \oplus G_i$.

| Gray bit | Operation | Binary bit |
|---|---|---|
| 1 | copy | 1 |
| 1 | $1 \oplus 1$ | 0 |
| 1 | $0 \oplus 1$ | 1 |
| 0 | $1 \oplus 0$ | 1 |
| 1 | $1 \oplus 1$ | 0 |

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

#### (FF)H AND (CA)H
AND is done bit by bit:

```text
 FFH = 1111 1111
 CAH = 1100 1010
 AND = 1100 1010
```

ANDing any bit with 1 leaves it unchanged, so FFH acts as a mask that passes the other number.

**Answer:** $(FF)_H \cdot (CA)_H = (CA)_H = (11001010)_2 = 202_{10}$

## Check yourself

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

1. What is the key property of Gray code?
   A. It is a weighted code
   B. Successive numbers differ in all bits
   C. It is 8421 weighted
   D. Successive numbers differ in only one bit
   Answer: D. This avoids false outputs on transitions. (Key point: Gray property)

2. Where is Gray code commonly used?
   A. Memory addressing in ROMs only
   B. Arithmetic adders
   C. BCD displays
   D. Shaft encoders and K-map labelling
   Answer: D. Single-bit changes make it reliable for these. (Key point: Uses)

3. What is (11101) Gray in binary?
   A. 11101
   B. 10011
   C. 10110
   D. 01101
   Answer: C. 1, 1^1=0, 0^1=1, 1^0=1, 1^1=0. (Key point: Conversion)

4. What is FFH AND CAH?
   A. FFH
   B. CAH
   C. 00H
   D. 35H
   Answer: B. ANDing any bit with 1 leaves it unchanged, so FFH passes CAH. (Key point: AND mask)

## Related in Digital Logic

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

- [Number conversions 33 to binary etc.](https://www.bctengineer.com/question.md?key=semester_2%2Fbasic_electronics_engineering%3Anumber-conversion-2067-chaitra) — Basic Electronics Engineering, chapter 6
- [TM that doubles a binary number](https://www.bctengineer.com/question.md?key=semester_3%2Ftheory_of_computation%3Atm-doubles-binary) — Theory of Computation, chapter 4
