Chapter 3: Number Systems
Introduction
Number systems are the fundamental way of
representing numbers in computing and mathematics. Understanding different
number systems is crucial for computer science and digital electronics. This
chapter will cover binary, octal, decimal, and hexadecimal number systems,
conversions between them, weighted and non-weighted codes, encoding schemes,
and the concepts of 1's complement and 2's complement.
Number
Systems
Binary
Number System
The binary number system uses only two digits: 0
and 1. It is the base-2 number system and is fundamental in computer science
because computers operate using binary logic.
Example
The binary number 1010 represents the decimal
number 10.
Octal
Number System
The octal number system uses eight digits: 0 to
7. It is the base-8 number system.
Example
The octal number 12 represents the decimal
number 10.
Decimal
Number System
The decimal number system uses ten digits: 0 to
9. It is the base-10 number system and is the most commonly used number system
by humans.
Example
The decimal number 10 represents ten.
Hexadecimal Number System
The hexadecimal number system uses sixteen
digits: 0 to 9 and A to F, where A represents 10, B represents 11, and so on up
to F, which represents 15. It is the base-16 number system.
Example
The hexadecimal number A represents the decimal
number 10.
Conversion Between Number Systems
Binary to
Decimal
To convert a binary number to decimal, multiply
each bit by 2 raised to the power of its position from right (starting from 0)
and sum the results.
To convert a decimal number to binary, divide
the number by 2 and record the remainder. Repeat the process with the quotient
until the quotient is 0. The binary number is the remainders read in reverse
order.
Example
Decimal 10:
10 ÷ 2 = 5, remainder 0
5 ÷ 2 = 2, remainder 1
2 ÷ 2 = 1, remainder 0
1 ÷ 2 = 0, remainder 1
Binary: 1010
Octal to
Decimal
To convert an octal number to decimal, multiply
each digit by 8 raised to the power of its position from right (starting from
0) and sum the results.
Decimal
to Octal
To convert a decimal number to octal, divide the
number by 8 and record the remainder. Repeat the process with the quotient
until the quotient is 0. The octal number is the remainders read in reverse
order.
Example
Decimal 10:
10 ÷ 8 = 1, remainder 2
1 ÷ 8 = 0, remainder 1
Octal: 12
Hexadecimal to Decimal
To convert a hexadecimal number to decimal,
multiply each digit by 16 raised to the power of its position from right
(starting from 0) and sum the results.
Decimal to Hexadecimal
To convert a decimal number to hexadecimal,
divide the number by 16 and record the remainder. Repeat the process with the
quotient until the quotient is 0. The hexadecimal number is the remainders read
in reverse order.
Example
Decimal 10:
10 ÷ 16 = 0, remainder 10 (A in hexadecimal)
Hexadecimal: A
Weighted
Codes
Binary-Coded Decimal (BCD)
BCD is a binary-encoded representation of
integer values that uses a 4-bit nibble to represent each digit of a decimal
number.
Example
Decimal 45:
4 in BCD: 0100
5 in BCD: 0101
BCD: 0100 0101
84-2-1
Code
A weighted code where each digit is represented
by a sum of weights 8, 4, -2, and -1.
Example
Decimal 5:
5 in 84-2-1: 0101
Non-Weighted Codes
Grey Code
Grey code is a binary numeral system where two
successive values differ in only one bit.
Example
Decimal 2:
Binary: 10
Grey Code: 11
Excess-3
Code
Excess-3 is a binary-coded decimal code that
adds 3 to each decimal digit and then encodes it in binary.
Example
Decimal 4:
4 + 3 = 7
Binary: 0111
Encoding
Schemes
ASCII
(American Standard Code for Information Interchange)
ASCII is a character encoding standard for
electronic communication, representing text in computers.
Example
Character A in ASCII: 65
ISCII
(Indian Script Code for Information Interchange)
ISCII is an encoding scheme for representing
Indian languages in computers.
Example
The character अ in ISCII: 164
Unicode
Unicode is a universal character encoding
standard that includes a repertoire of over 143,000 characters covering 154
modern and historic scripts.
Example
Character अ in
Unicode: 0905
1’s
Complement
1’s complement of a binary number is obtained by
inverting all the bits (changing 0 to 1 and 1 to 0).
Example
Binary 1010:
1’s Complement: 0101
2’s
Complement
2’s complement of a binary number is obtained by
inverting all the bits and adding 1 to the least significant bit.
Example
Binary 1010:
1’s Complement: 0101
Add 1: 0101 + 1 = 0110
2’s Complement: 0110
Conclusion
Understanding number systems and their
conversions, codes, and encoding schemes is essential for anyone involved in
computer science and digital electronics. This knowledge forms the foundation
for more advanced topics in computing.
References
1. Digital Design and Computer Architecture by
David Harris and Sarah Harris.
2. Computer System Architecture by M. Morris
Mano.
3. Fundamentals of Digital Logic with Verilog
Design by Stephen Brown and Zvonko Vranesic.
4. The Unicode Standard. Retrieved from
[Unicode](https://www.unicode.org/).
5. ASCII Table. Retrieved from [ASCII
Table](https://www.asciitable.com/).
Comments
Post a Comment