Number Systems and Codes
Number Systems and Codes are foundational for understanding digital circuits and data representation.
Drafted with Aria, reviewed by the AiCanCode.org team. Spotted an error? Use Give Feedback at the bottom of the page.
Why it matters
Understanding number systems and codes is crucial for designing and analyzing digital circuits, which form the backbone of modern electronic devices. These concepts are essential for data representation, processing, and communication in digital systems.
Key ideas
- Number Systems: The most common number systems in digital electronics are binary, octal, decimal, and hexadecimal. Each system has a different base: binary (base 2), octal (base 8), decimal (base 10), and hexadecimal (base 16).
- Binary System: Uses two symbols, 0 and 1. It is the fundamental language of computers.
- Octal System: Uses eight symbols, 0 to 7. It is often used as a shorthand for binary numbers.
- Decimal System: Uses ten symbols, 0 to 9. It is the standard system for human-centric calculations.
- Hexadecimal System: Uses sixteen symbols, 0 to 9 and A to F. It is used in computing as a more human-friendly representation of binary-coded values.
- Conversions: Converting numbers between different bases is a key skill. This includes binary to decimal, decimal to binary, binary to hexadecimal, and vice versa.
- Codes: Codes like BCD (Binary-Coded Decimal), Gray code, and ASCII are used for specific applications in digital systems.
- BCD: In standard 8421 BCD, represents each decimal digit with four bits; codes 1010 through 1111 are invalid digits.
- Gray Code: A binary numeral system where two successive values differ in only one bit, useful in minimizing errors in digital circuits.
- ASCII: A character encoding standard for electronic communication, representing text in computers.
Formulas
- Binary positional expansion:
N = Σ(d_i * 2^i)N: Decimal numberd_i: Binary digit at positionii: Position index (starting from 0)
- Binary to Decimal:
N = Σ(b_i * 2^i)N: Decimal numberb_i: Binary digit at positionii: Position index (starting from 0)
Worked example
Convert the decimal number 156 to binary.
Divide the number by 2 and record the remainder.
Continue dividing the quotient by 2 until the quotient is 0, recording each remainder.
The binary equivalent is the remainders read in reverse order.
- 156 ÷ 2 = 78 remainder 0
- 78 ÷ 2 = 39 remainder 0
- 39 ÷ 2 = 19 remainder 1
- 19 ÷ 2 = 9 remainder 1
- 9 ÷ 2 = 4 remainder 1
- 4 ÷ 2 = 2 remainder 0
- 2 ÷ 2 = 1 remainder 0
- 1 ÷ 2 = 0 remainder 1
Binary equivalent: 10011100
An unsigned N-bit integer ranges from 0 to 2^N−1; two’s-complement signed integers range from −2^(N−1) to 2^(N−1)−1. For example, 10011100 is 156 unsigned but −100 as 8-bit two’s complement. State signedness and width.
Common mistakes
- Confusing the bases during conversion, especially between binary and hexadecimal.
- Incorrectly aligning bits when converting between binary and BCD.
- Forgetting to reverse the order of remainders when converting from decimal to binary.
For GATE EC
Questions often involve converting numbers between different bases, understanding and applying different codes, and solving problems related to error detection and correction. Practice converting numbers and understanding the application of different codes in digital systems.
Quick check
- Convert the binary number 1011 to decimal.
- What is the hexadecimal equivalent of the binary number 110101?
- How many bits are required to represent the decimal number 255 in binary?
Answers: 1. 11 in decimal. 2. 0x35 in hexadecimal. 3. 8 bits for an unsigned representation.
Finished this topic? Mark it so your progress, study plan and readiness keep up.
Stuck on something here?