- Related Questions & Answers
- C++ Program to Convert Hexadecimal Number to Binary
- How to Convert Decimal to Binary, Octal, and Hexadecimal using Python?
- How to Convert Decimal to Hexadecimal?
- How to Convert Hexadecimal to Decimal?
- How to convert Decimal to Hexadecimal in Java
- How to convert decimal to hexadecimal in JavaScript?
- Java Program to convert integer to hexadecimal
- Java Program to convert from decimal to hexadecimal
- Convert a Number to Hexadecimal in C++
- How to Convert Binary to Decimal?
- How to Convert Decimal to Binary?
- How to Convert Binary to Octal?
- How to Convert Octal to Binary?
- How to convert an integer to a hexadecimal string in Python?
- Java program to convert decimal number to hexadecimal number

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

**Binary** is the simplest kind of number system that uses only two digits of 0 and 1 (i.e. value of base 2). Since digital electronics have only these two states (either 0 or 1), so binary number is most preferred in modern computer engineer, networking and communication specialists, and other professionals.

Whereas **Hexadecimal** number is one of the number systems which has value is 16 and it has only 16 symbols − 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 and A, B, C, D, E, F. Where A, B, C, D, E and F are single bit representations of decimal value 10, 11, 12, 13, 14 and 15 respectively.

Hexadecimal number system provides convenient way of converting large binary numbers into more compact and smaller groups. There are various ways to convert a binary number into hexadecimal number. You can convert using direct methods or indirect methods. First, you need to convert a binary into other base system (e.g., into decimal, or into octal). Then you need to convert it hexadecimal number.

Most Significant Bit (MSB) | Hexa Point | Least Significant Bit (LSB) | |||
---|---|---|---|---|---|

16^{2} | 16^{1} | 16^{0} | 16^{-1} | 16^{-2} | 16^{-3} |

256 | 16 | 1 | 1/16 | 1/256 | 1/4096 |

Since number numbers are type of positional number system. That means weight of the positions from right to left are as 16^{0}, 16^{1}, 16^{2}, 16^{3}and so on. for the integer part and weight of the positions from left to right are as 16^{-1}, 16^{-2}, 16^{-3}and so on. for the fractional part.

**Example** − Convert binary number 1101010 into hexadecimal number.

First convert this into decimal number: = (1101010)_{2}= 1x2^{6}+1x2^{5}+0x2^{4}+1x2^{3}+0x2^{2}+1x2^{1}+0x2^{0}= 64+32+0+8+0+2+0 = (106)_{10}Then, convert it into hexadecimal number = (106)_{10}= 6x16^{1}+10x16^{0}= (6A)_{16}which is answer.

However, there is also a direct method to convert a binary number into hexadecimal number − grouping which is explained as following below.

Since, there are only 16 digits (from 0 to 7 and A to F) in hexadecimal number system, so we can represent any digit of hexadecimal number system using only 4 bit as following 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 bit of binary input number, then replace each group of binary number from its equivalent hexadecimal digits. That will be hexadecimal number of given number. Note that you can add any number of 0’s in leftmost bit (or in most significant bit) for integer part and add any number of 0’s in rightmost bit (or in least significant bit) for fraction part for completing the group of 4 bit, this does not change value of input binary number.

So, these are following steps to convert a binary number into hexadecimal number.

Take binary number

Divide the binary digits into groups of four (starting from right) for integer part and start from left for fraction part.

Convert each group of four binary digits to one hexadecimal digit.

This is simple algorithm where you have to grouped binary number and replace their equivalent hexadecimal digit.

**Example-1** − Convert binary number 1010101101001 into hexadecimal number. Since there is no binary point here and no fractional part. So,

Therefore, Binary to hexadecimal is,

= (1010101101001)_{2}= (1 0101 0110 1001)_{2}= (0001 0101 0110 1001)_{2}= (1 5 6 9)_{16}= (1569)_{16}

**Example-2** − Convert binary number 001100101.110111 into hexadecimal number. Since there is binary point here and fractional part. So,

Therefore, Binary to hexadecimal is,

= (001100101.110111)_{2}= (0 0110 0101 . 1101 1100)_{2}= (0110 0101 . 1101 1100)_{2}= (6 5 . D C)_{16}= (65.DC)_{16}

These are above simple conversions binary number to hexadecimal number.

Advertisements