## Why do we need various number systems in computer science?

Computers cannot understand human languages. So, to process commands and instructions given by programmers, they use different systems typically known as number systems.

The most widely used number systems are:

- Binary
- Octal
- Decimal
- Hexadecimal

All of these are equally important. In the article below, you will learn what these numbers are and some of their applications.

## 1. Binary system

Binary system aka Base-2 number system is used by computers to operate. All the data stored in a computer consists of binary numbers. It is the most widely used system.

Binary consists of two units **0** and **1**, known as bit. Individually the **0** bit means NO (False) while 1 bit means YES (True).

These bits are combined in a group of 8 bytes, to represent multiple characters and values. One byte can represent 256 values depending on its arrangement of bit units.

Binaries are stored in computer data as “Machine code”. This way its CPU can execute programs set by the computer scientists.

In the binary system, there is no representation for negative integers because we only have 0 and 1. No -ve sign no +ve sign. So to represent such numbers and perform similar operations, programmers use two’s complement.

You can find two’s complement of binary numbers using two’s complement calculator.

**Note**:

Source code is not to be confused with Machine code. Source code is designed by programmers in languages such as HTML, Python, etc.

To understand this source code, the computer converts it into binary numbers, Machine code.

__Use of binary number system:__

- It can be used to represent pixels of an image.
- It also used to represent On and OFF in a circuit.
- True and False statements.
- ASCII

__Conversion in Binary:__

Although it is mostly used in computers, humans can also learn this system easily.

** Example**:

Convert **345** into Binary Number.

**Solution**:

- Perform repeated division on 345 with 2 as a divisor.

- Start writing from bottom to top.
**10010**

- Complete 8-bit byte by adding zeros on the left.
**00010010**

## 2. Octal Number system

Base-8 is a number system that has 8 as the radix. The 8 digits used in this system are 0, 1, 2, 3, 4, 5, 6, 7. All of these representations can be arranged variously to make more octal representations.

The octal number system is a little confusing and needs the practice to understand it completely. An Octal number is usually expressed with 8 as subscript e.g.**.**

Computers cannot read octal numbers directly. That’s why they are converted into binary first.

In octal numbers, digits above 7 are represented differently. For example, 8 is represented as 10 which is actually 1 + 0, not the decimal 10. To clarify it even more.

## Octal Numbers:

Decimal Number |
3-bit Binary Number |
Octal Number |

## 0 |
## 000 |
## 0 |

## 1 |
## 001 |
## 1 |

## 2 |
## 010 |
## 2 |

## 3 |
## 011 |
## 3 |

## 4 |
## 100 |
## 4 |

## 5 |
## 101 |
## 5 |

## 6 |
## 110 |
## 6 |

## 7 |
## 111 |
## 7 |

## 8 |
## 001 000 |
## 10 (1+0) |

## 9 |
## 001 001 |
## 11 (1+1) |

__Use of Octal Numbers:__

- In UNIX
- Computing graphics
- File Protection

__Conversion in Octal:__

Conversion in octal is quite similar to conversion in binary.

** Example**:

Convert **130** in Octal.

**Solution**:

- Perform repeated division on 130.

- Start writing from bottom to top.

**(202)****8**

## 3. Decimal system

The decimal system aka the Base-10 system is the number system with which almost every human is familiarized. Even an uneducated person can understand this system.

The reason is that we use it in daily life in finance, counting e.t.c. The numbers used in the denary system are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9.

In the denary system, the significance of each number increases by 10 times as we move from right to left. E.g in the number **56**, 5 is 10 times more valuable than the number 6.

__Uses of the decimal system:__

- Finance
- Calendar
- Counting

__Conversion in decimal:__

There isn’t much to do in decimal conversion because it is the number system we are using. This means that the numbers we use are already presented in the denary system.

But we can learn to convert binary numbers in the decimal system.

**Example**:

Convert **10010101** in decimal.

**Solution:**

- First, write 2 under each bit with power the same as the position of it.

- Now, multiply the numbers with their respected binary bit and add them. i.e.,

= 128 + 16 + 4 + 1

= 149

## 4. Hexadecimal system

The last and the most complex number system is the hexadecimal system. It is difficult to learn as compared to other number systems.

This number system makes several things convenient such as the representation of bytes. Only 2 hexadecimal numbers are required to represent an 8-bit byte of binary numbers.

It is also known as base-16 and the digits and alphabets used in this system are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.

The alphabet A represents decimal number 10, B represents decimal number 11, and so on.

__Uses of Hexadecimal:__

- Memory locations
- De-bugging
- To define colors on web pages e.g A shade of red is represented by ff0000.

Decimal Number | 4-bit Binary Number | Hexadecimal Number |

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 | F |

16 | 0001 0000 | 10 (1+0) |

17 | 0001 0001 | 11 (1+1) |

__Conversion in hexadecimal:__

To convert decimal into hexadecimal, the same method as the octal conversion is used.

** Example**:

Convert **510** in hexadecimal.

**Solution**:

- Perform repeated division on 510.

- Write from bottom to top and use the respected alphabets where needed.

14 = E, 15 = F, 1 = 1

- Hence,

510 = **(1FE)****16**

## Conclusion

Each number system is important and has various applications. It is due to these number systems that modern computers can perform much more tasks than the old ones.

Although these systems are used in computer programming, they can be easily learned because ultimately they all are related to the decimal number system that humans use.

- How to write a resume for a job search: Tips for applicants - May 11, 2021
- The Best Tool to Test the Speed of Your Internet - May 5, 2021
- Why do we need various number systems in computer science? - April 16, 2021