This post is also available in: हिन्दी (Hindi) العربية (Arabic)

When we type words onto a computer, it translates them into numbers. In fact, to a computer, all information is written as a series of 1s and 0s, i.e., in computer number systems are that’s how we represent numbers in a computer system architecture.

Number systems are one of the most fundamental concepts that computer scientists must learn. It’s an important step for anyone who wants to become a computer scientist or programmer.

In this article, we will introduce you to the number systems that are essential for a computer scientist and also explore binary and hexadecimal number system in computer.

## What is a Computer Number System?

Humans have been counting for a long time. To do so, we use systems that relate unique symbols to specific values. This is called a number system, and it is the technique that we use to represent and manipulate numbers.

You are probably most familiar with the decimal system that forms the basis of how humans count. The decimal system has a base of 10 because it provides 10 symbols to represent all numbers – 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9.

Humans use the decimal system because we have 10 fingers to count on, but machines don’t have that luxury. So, we’ve created other number systems that perform the same functions. Computers represent information differently than humans, so we need different systems to represent numbers.

Commonly used number systems in computers are

- Binary
- Hexadecimal

## Binary Number System in Computer

A computer uses bits to represent information. A bit is the most basic unit of storage in a computer. An essential component of computers is called the transistor. Just like a light switch, the transistor either allows or prevents current to flow. So, it only has two states – ON and OFF.

Every number in a computer is an electrical signal. In the early days of computers, electrical signals were represented with an “ON” state (a negative charge) and an “OFF” state (a positive charge). This forms a kind of binary switch.

These two states can be represented using one of the two symbols – 1 and 0. This means that the binary number system has a base of 2. Only these two symbols are needed to represent every number.

This is called the binary number system. Each binary digit is referred to as a bit. When it comes to binary to place values and digits in this system, we place values corresponding to ascending powers of 2 from left to right.

You can manipulate bits left and right with bitwise operators to efficiently change the value of a number at the machine code level.

## Hexadecimal Number System in Computer

Another common number system used is the hexadecimal number system in computer. Binary numbers are easy for computers but not so easy for humans to understand. And when you’re working with large numbers, it becomes difficult to both read and write without error. So, to fix this problem binary numbers are arranged into groups of four bits, forming the hexadecimal number system.

The hexadecimal number system in computer (often called “hex”) is made up of 16 symbols, so it has a base of 16. Hexadecimal uses the 10 numbers of the decimal system and six extra symbols A, B, C, D, E, and F.

Hexadecimal: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F

Decimal: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15

## Conversion of Numbers Between Binary and Hexadecimal Number System in Computer

Since there are 16 digits (from 0 to 9 and A to F) in the hexadecimal number system, so we can represent any digit of the hexadecimal number system using only 4 bits as below:

Hexa | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Binary | 0000 | 0001 | 0010 | 0011 | 0100 | 0101 | 0110 | 0111 |

Hexa | 8 | 9 | A | B | C | D | E | F |

Binary | 1000 | 1001 | 1010 | 1011 | 1100 | 1101 | 1110 | 1111 |

So, if you make each group of 4 bits of binary input number, then replace each group of binary numbers with its equivalent hexadecimal digits. That will be the hexadecimal number of a given number.

Note that you can add any number of 0’s in a leftmost bit (or in the most significant bit) for the integer part and add any number of 0’s in the rightmost bit (or in the least significant bit) for the fraction part for completing the group of 4 bit, this does not change the value of input binary number.

Let’s convert 1010101101101 to hexadecimal.

1010101101001 (Making group of four from right) = (0001) (0101) (0110) (1101) = 156D

Consider another binary number 11100001100110

11100001100110 (Making group of four from right) = (0011) (1000) (0110) (0110) = 3866

Similarly one can convert hexadecimal to binary.

Let’s convert B57E to binary.

B57E = (1011) (0101) (0111) (1110) = 1011010101111110

## Advantages of Hexadecimal Number System in Computer

The main advantage of a Hexadecimal Number is that it is very compact and using a base of 16 means that the number of digits used to represent a given number is usually less than in binary or decimal. Also, it is quick and easy to convert between hexadecimal numbers and binary.

Here are some advantages of using the hexadecimal number system in computer:

- It is very concise and using a base of 16 means that the number of digits used to signify a given number is usually less than in binary or decimal. It allows you to store more information using less space.
- It is fast and simple to convert between hexadecimal numbers and binary. Hexadecimal can be used to write large binary numbers in just a few digits.
- It makes life easier as it allows grouping of binary numbers which makes it easier to read, write and understand. It is more human-friendly, as humans are used to grouping together numbers and things for easier understanding. Also, writing in fewer digits lowers the possibility of an error occurring.

## Uses of hexadecimal Number System in Computer

A hexadecimal number system in computer is often used by programmers to simplify the binary numbering system. Since 16 is equivalent to 2^{4}, there is a linear relationship between the numbers 2 and 16.

This means that one hexadecimal digit is equivalent to four binary digits. Computers use binary numbering systems while humans use hexadecimal numbering systems to shorten binary and make it easier to understand.

Hexadecimal is used in the following:

**To define locations in memory:**Hexadecimals can characterize every byte as two hexadecimal digits only compared to eight digits when using binary.**To define colours on web pages:**Each primary colour – red, green, and blue is characterized by two hexadecimal digits. The format being used is #RRGGBB. RR stands for red, GG stands for green and BB stands for blue.**To represent Media Access Control (MAC) addresses:**MAC addresses consist of 12-digit hexadecimal numbers. The format being used in either MM:MM:MM:SS:SS:SS or MMMM-MMSS-SSSS. The first 6 digits of the MAC address represent the ID of the adapter manufacturer while the last 6 digits represent the serial number of the adapter.**To display error messages:**Hexadecimals are used to define the memory location of the error. This is useful for programmers in finding and fixing errors.