top of page

How to Use the BIN2HEX Function

How to use the BIN2HEX Function in Excel

The BIN2HEX function converts binary numbers into hexadecimal numbers.

Contents:


Syntax

= BIN2HEX(number, [places])

number - The binary number you wish to convert to a hexadecimal number

[places] - Optional, number of significant digits to pad the hexadecimal number


Note: binary numbers can be in text or number form, either 1001 or "1001" will work


Explanation

The BIN2HEX function is part of the "Engineering" group of functions within Excel.


This function takes in binary numbers and converts them into hexadecimal


The binary number can be up to 10 characters, or bits, in length. If the length exceeds this, a #NUM error will be returned.


This means the largest number than can be represented is "111111111" or 511.


When using the optional places argument, the places number will pad the returned binary number with zeros.


Hexadecimal represents binary data more compactly than binary or decimal, as one hex digit can represent four binary digits (bits), making it efficient for displaying large values.


What is a Binary Number

A binary number is a number expressed in the base-2 numeral system, which uses only two symbols, 0 and 1.


Each digit in a binary number is a bit, and the value of each bit is based on its position, with each position representing a power of 2, increasing as you move from right to left.

understanding how binary numbers are calculated

In this example, instead of the base increasing by 10x as we go up, the base is increased by 2x each step.


Each 0 and 1 value in the binary number is multiplied by the base, and the sum of all of the multiplied values is the corresponding decimal number.


What is a Hexadecimal Number

The hexadecimal number system uses base 16, and uses the standard 0-9 digits, but also includes the letters A-F to represent higher numbers.


Hexadecimal Number Table

This table shows the hexadecimal version of the standard decimal numbers that we are used to working with.


Because hexadecimals use a base 16, this means that the as the numbers of digits increase, their place value, increases by a power of 16. The first being 16^0 = 1, next being 16^1 = 16, 16^2 = 256, and so on.


If we look at it visually, it would look like this:

understanding how binary numbers are calculated

In this example, the hexadecimal number 2B3 is calculated by multiplying the first value , "3", by 1, the second value "B" which represents 11 by 16, and finally the third value "2" by 256, and then adding them all together to get 691.


Examples

How to Convert Binary Number to Hexadecimal

Let's say we have table of binary numbers, and need to convert them into hexadecimal.

excel convert binary number to hexadecimal with formula

The formula to convert from binary to hexadecimal would be:

= BIN2HEX(binary_number)

If we plug this formula into the table, the formula returns the correct hexadecimal number.

convert binary numbers to hexadecimal numbers in excel

Using the BIN2HEX function in the right column lets us easily convert multiple binary numbers at once.

excel convert binary string to hexadecimal

bottom of page