So far, we are accustomed to the decimal number system. In this article, we are going to explore more types of number systems which is – Binary and Hexadecimal Number system, and why it is important in computers.

## Number system

As you may already know that a decimal number system has 10 digits(0 to 9)and has a base 10. Similarly and as the name suggests, a binary number has two digits(0 and 1) and has a base of 2 and Hexadecimal has 15 digits(0 to 9 and A to F) and has a base of 16.

## Why does it matter here?

Yeah, that’s what I thought first. But trust me, you need to know about it. All the numbers stored in the computer is in binary. The smallest memory unit(bit) can store 2 numbers(0 and 1). So imagine any number and that is stored in a binary form on the computer.

Also, there are many times when you need to do bitwise shift operations and for that alone, you should know about binary numbers.

## What are Binary Numbers

A binary number has a base of 2 and contains two digits – 0 and 1. Just like in decimal, for a number greater than 9, we add another digit in front of the number. Similarly, if you want to store a number greater than 1, you have to add another digit in front of it. For example:

Decimal Number | Binary Number |

2 | 10 |

3 | 11 |

4 | 100 |

5 | 101 |

6 | 110 |

7 | 111 |

Now, you can calculate the binary number from a digital number and I am not going to talk about the process here. You can watch this video.

But here is the problem, As you can see the conversion is a plain hectic and writing binary number in itself takes up a lot of space. So to perform a simple operation, you need a lot of space and there is more room for errors.

So there is another type of number system that solves this and that is **Hexadecimal Number System.**

**Hexadecimal Number System**

In Hexadecimal, the base if a number is 16. So there are 16 digits it supports and that are:0 to 9 and A to F. Here A is 10, B is 11 C is 12, D is 13, E is 14 and F is 15. So, if you want to store a number greater than 15, you have to add another digit in front of it. For example:

Decimal Number | Hexadecimal |

16 | 10 |

17 | 11 |

32 | 20 |

# Convert Binary to Hexadecimal Number

Well, the conversion from binary number to hexadecimal is really simple.

Binary Number | Hex Number |

0000 | 0 |

0001 | 1 |

0010 | 2 |

0011 | 3 |

0100 | 4 |

0101 | 5 |

0110 | 6 |

0111 | 7 |

1000 | 8 |

1001 | 9 |

1010 | A |

1011 | B |

1100 | C |

1101 | D |

1110 | E |

1111 | F |

## Steps to Convert Binary to Hexadecimal

Binary is easy to convert to hex.

- Start from the least significant bit (LSB) at the right of the binary number and divide it up into groups of 4 digits. (4 digital bits is called a “
**nibble**“). - Convert each group of 4 binary digits to its equivalent hex value.
- Concatenate the results together, giving the total hex number.

Well, you don’t need to remember the table. You just have to know the binary to decimal conversion and if the number is greater than 9, just convert it to it’s hexadecimal. For example, 1010 converts to 10, just replace that with A.

# How does this solve the Problem?

As you can see, the conversion of binary to hexadecimal is much easier than from binary to decimal. This makes it easier to operate on binary, you just need to convert the number into hexadecimal and operate hexadecimal. Conversion of hexadecimal into binary is also really easy. For example, you have to convert A Hex number AB. Just replace the number into its binary counterpart and concatenate it.

A- 1010

B- 1011

So the binary number should be 10101011.

# Hexadecimal Number Used

It is used in the assembly language of the computer system. Also while working on embedded systems, you will come across various registers and you can configure it’s value to your suitability. For doing that, you should know about binary and hexadecimal number systems.

I think that’s it for this article, do reach me out in the comment section for any feedback and questions.