# Computer Number Systems – Decimal, Binary, Octal, Hexadecimal

## The number system is a basis for counting various items. On hearing the word ‘number’ all of us immediately think of the familiar decimal number system with its 10 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9.

**Introduction**

The number system is a basis for counting various items. On hearing the word ‘number’ all of us immediately think of the familiar decimal number system with its 10 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9.

Modern computers communicate and operate with binary numbers which use only the digits 0 and 1. Let us consider decimal number 18. This number is represented in binary as 10010. In the example, if a decimal number is considered, we require only two digits to represent the number, whereas if the binary number is considered we require five digits. Therefore we can say that when decimal quantities are represented in the binary form, they take more digits.

For large decimal numbers, people have to deal with very large binary strings, and therefore, they do not like working with binary numbers. This fact gave rise to three new number systems: octal, hexadecimal, and Binary Coded Decimal(BCD). This number system represents binary numbers in a compressed form. Therefore these number systems are now widely used to compress long strings of binary numbers.

In this topic, we discuss binary, octal, hexadecimal, and BCD number systems and we will see how to convert from decimal to binary, octal and hexadecimal, and vice versa.

**Decimal Number System:**

Before considering any number system, let us consider a familiar decimal number system we can express any decimal number in units, ten hundred, thousands, and so on. When we write a decimal number say 5678.9, we know it can be represented as

**5000+600+70+8+0.9=5678.9**

The decimal number 5678.9 can also be written as 5678.910, where the 10 subscript indicates the radix or base.

This says that the position of the digit with reference to the decimal point determines its value/weight. The sum of all the digits multiplied by their weights gives the total number being represented. The left-most digit, which has the greatest weight is called the most significant digit and the rightmost digit, which has the least weight, is called the least significant digit.

**Binary Number System:**

We know that the decimal system with its ten digits is a base-ten system. Similarly, a binary system with its two digits is a base-two system. The two binary digits (bits) are 1 and 0. Like a digital system, in the binary system, each binary digit commonly known as bit has its own value or weight. However, in binary systems weight is expressed as a power of 2.

**Octal Number System:**

We know that the base of the decimal number system is 10 because it uses the digits 0 to 9, and the base of the binary system is 2 because it uses digits 0 and 1. The octal number system uses the first eight digits of the decimal number system: 0, 1, 2, 3, 4, 5, 6, and 7. As it uses 8 digits, its base is 8.

**Hexadecimal Number System:**

The hexadecimal number system has a base of 16 having 16 digits: 0,1,2,3,4,5,6,7,8,9, A, B, C, D, E, and F. It is another number system that is particularly useful for human communications with a computer. Although it is somewhat more difficult to interpret that the octal number system has become the most popular. Since its base is a power of 2 (2-4), it is easy to convert hexadecimal numbers to binary and vice versa.

DECIMAL |
BINARY |
HEXADECIMAL |

0 | 0000 | 0 |

1 | 0001 | 1 |

2 | 0010 | 2 |

3 | 0011 | 3 |

4 | 0100 | 4 |

5 | 0101 | 5 |

6 | 0110 | 6 |

7 | 0111 | 7 |

8 | 1000 | 8 |

9 | 1001 | 9 |

10 | 1010 | A |

11 | 1011 | B |

12 | 1100 | C |

13 | 1101 | D |

14 | 1110 | E |

15 | 1111 | 7 |