Posts

Showing posts from September, 2025

Gray Code in Digital Electronics – Binary to Gray and Gray to Binary Conversion

Image
Introduction In Digital Electronics , codes are used to represent numbers and data efficiently. One such code is the Gray Code , also known as the Reflected Binary Code . Unlike normal binary numbers, Gray Code ensures that only one bit changes at a time between successive numbers. This makes it highly useful in error detection, position encoders, and digital systems . In this blog, we’ll learn: What is Gray Code? Properties of Gray Code Conversion: Binary to Gray Code Conversion: Gray Code to Binary Applications of Gray Code What is Gray Code? Gray Code is a non-weighted code . It differs from BCD and Excess-3 codes, which are weighted. In Gray Code, only one bit changes when moving from one value to the next. Also called Unit Distance Code because only one bit differs between consecutive codes. Example (4-bit Gray Code sequence): 0000, 0001, 0011, 0010, 0110, 0111, 0101, 0100, 1100, … Notice how only one bit changes each time. Conversion Methods B...

Excess-3 (XS-3) Code in Digital Electronics – Explained with Examples

Image
 Introduction In digital electronics, numbers are often represented in binary-coded forms to make processing easier for computers. One such code is the Excess-3 Code (XS-3) , which is widely used in arithmetic operations and error detection. Excess-3 is a non-weighted code derived from the standard 8421 BCD code . It is called “excess-3” because the value 3 is added to each decimal digit before converting it to binary . What is Excess-3 Code? A self-complementing code → the 9’s complement of a decimal digit can be obtained directly by complementing its Excess-3 representation. Each decimal digit (0–9) is represented by its BCD code + 0011 (3 in binary) Conversion Method Decimal → Excess-3 Write the decimal digit. Add 3 to it. Convert the result into 4-bit binary. Example: Convert Decimal 59 into Excess-3 Code Decimal 5 → 5 + 3 = 8 → 1000 Decimal 9 → 9 + 3 = 12 → 1100 So, 59 = 1000 1100 (Excess-3 Code) Excess-3 → Decimal Take the Excess-3 code. ...

Decimal to BCD Conversion (8421, 5421, 2421 Codes) – Digital Electronics

Image
Introduction In Digital Electronics, Binary Coded Decimal (BCD) is a way to represent decimal numbers (0–9) in binary form. Instead of converting the whole decimal number into a binary equivalent, each decimal digit is represented separately by a 4-bit binary code . There are different types of BCD codes depending on the weights assigned to each binary digit: 8421 Code (Natural BCD, Weighted Code) 5421 Code (Weighted Code) 2421 Code (Self-Complementing Weighted Code) Let’s understand each one in detail. 1. 8421 BCD Code (Natural Binary Coded Decimal) This is the most common BCD code . Each digit has positional weights: 8, 4, 2, 1 Decimal numbers 0–9 are represented as 0000–1001       Decimal     8421 BCD 0 0000 1 0001 2 0010 3 0011 4 0100 5 0101 6 0110 7 0111 8 1000 9 1001 Example: Convert Decimal 59 into 8421 BCD 5 → 0101 9 → 1001 So, 59 = 0101 1001 (BCD) 2. 5421 BCD Code In this system, the weights are: 5, 4, 2, 1 Each decima...