---
title: "Convert (01010111)gray to binary"
subject: "Digital Logic"
chapter: 1
key: "semester_3/digital_logic:convert-gray-01010111-binary"
source: https://www.bctengineer.com/q/semester_3/digital_logic/convert-gray-01010111-binary
site: BCT Engineering
---

# Convert (01010111)gray to binary

Digital Logic · Chapter 1: Introduction

- Asked in: 2079 Bhadra, 1.5 marks
- Video: [class 4 by Dr. M. Nilesh sir binary to grey code conversion & vice versa](https://www.youtube.com/watch?v=Qs1JPqFF_oA) — Dr. M. Nilesh
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_3/digital_logic/convert-gray-01010111-binary
- Whole chapter: https://www.bctengineer.com/md/semester_3/digital_logic/chapter-1

## Question

Convert (01010111)gray = (?)₂.

## Short answer

MSB of binary equals MSB of Gray (0). Each next binary bit = previous binary bit XOR current Gray bit: 0⊕1=1, 1⊕0=1, 1⊕1=0, 0⊕0=0, 0⊕1=1, 1⊕1=0, 0⊕1=1. Result: (01100101)₂.

## Answer

**Rule (Gray to binary):** the MSB of binary equals the MSB of Gray. Each next binary bit = previous binary bit XOR current Gray bit, $B_i = B_{i+1} \oplus G_i$.

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

Check: converting 01100101 back to Gray ($G_i = B_{i+1} \oplus B_i$) gives 01010111 again.

**Answer:** $(01010111)_{gray} = (01100101)_2$ (= $101_{10}$).

## Check yourself

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

1. In Gray to binary conversion, what is the binary MSB?
   A. Always 1
   B. The complement of the Gray MSB
   C. XOR of the two MSBs
   D. Equal to the Gray MSB
   Answer: D. The MSB is copied unchanged. (Key point: Gray MSB rule)

2. How is each next binary bit found?
   A. Previous Gray bit XOR current Gray bit
   B. Previous binary bit AND current Gray bit
   C. Previous binary bit XOR current Gray bit
   D. Current Gray bit complemented
   Answer: C. B_i = B_(i+1) XOR G_i. (Key point: Gray to binary rule)

3. What is (01010111) Gray in binary?
   A. 01010111
   B. 01100101
   C. 01101001
   D. 10011010
   Answer: B. Applying the XOR chain from the MSB gives 0,1,1,0,0,1,0,1. (Key point: Final result)

4. How can the result be checked?
   A. Convert it back to Gray with G_i = B_(i+1) XOR B_i
   B. Add 1 to it
   C. Take its 2's complement
   D. Subtract 3 from each group
   Answer: A. Binary to Gray must give the original code back. (Key point: Verification)

## 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
- [Convert (110111)gray to binary](https://www.bctengineer.com/question.md?key=semester_3%2Fdigital_logic%3Aconvert-gray-110111-binary) — 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
- [Convert (101001001)₂ to Gray](https://www.bctengineer.com/question.md?key=semester_3%2Fdigital_logic%3Aconvert-binary-to-gray-101001001) — 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
