The HEX2BIN function converts binary numbers into hexadecimal numbers.
Contents:
Syntax
= HEX2BIN(number, [places])
number - The hexadecimal number you wish to convert to binary [places] - Optional, number of significant digits to pad the binary number
Explanation
The HEX2BIN function is part of the "Engineering" group of functions within Excel.
This function takes in hexadecimal numbers and converts them into binary.
The returned binary number can only 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" in binary, 1FF in hexadecimal or 511 in decimal .
When using the optional places argument, the places number will pad the returned binary number with zeros to the left.
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 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.
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:
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.
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.
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.
Examples
How to Convert Hexadecimal Numbers to Binary
Let's say we have table of hexadecimal numbers, and need to convert them into binary.
The formula to convert from hexadecimal to binary would be:
= HEX2BIN(hexadecimal_number)
If we plug this formula into the table, the formula returns the correct binary number.
Using the HEX2BIN function in the right column lets us easily convert multiple hexadecimal numbers at once.