How to use the HEX2BIN function
The HEX2BIN function converts a hexadecimal number to a binary number.
What is a hexadecimal number?
A hexadecimal number is a numeral system with a base of 16, for example, the decimal system uses a base of 10. This means that each digit in a hexadecimal number can have 16 possible values, from 0 to 15, however, the letters A to F are used from 10 to 15. See the hexadecimal column in the table below.
Hexadecimal numbers are often used in computers, the reason is they represent four binary digits (bits) with one hexadecimal digit. For example, the binary number 1010 is equivalent to the hexadecimal number A.
Hexadecimals make it easier to write big numbers with less digits, in other words, hexadecimals shorten binary digits considerably. For example, we can use hexadecimal to show the values of colors and MAC addresses in computers.
What is a binary number?
The binary system is a positional numeral system that uses only two digits: 0 and 1. The binary system is important in our society, many devices like computers, digital cameras, mobile phones and modern cars use binary code to store, process and communicate data. The binary numeral system makes it easy to store and transmit data using binary digits or bits.
Hexadecimal | Binary |
0 | 0 |
1 | 1 |
2 | 10 |
3 | 11 |
4 | 100 |
5 | 101 |
6 | 110 |
7 | 111 |
8 | 1000 |
9 | 1001 |
A | 1010 |
B | 1011 |
C | 1100 |
D | 1101 |
E | 1110 |
F | 1111 |
10 | 10000 |
Table of Contents
1. HEX2BIN Function Syntax
HEX2BIN(number, [Places])
2. HEX2BIN Arguments
number | Required. The hexadecimal number you want to convert to a decimal number. |
[Places] | Optional. How many digits to use, if omitted HEX2BIN uses the minimum number of required digits. Tip! Use [Places] for padding with leading 0's (zeros).
HEX2BIN function ignores [Places] argument if the hexadecimal is negative. |
3. HEX2BIN Function Example
The image above demonstrates the HEX2BIN function cell C3, C4, C5, and C6. It calculates the binary values based on the corresponding cells which contain different hexadecimal numbers.
Formula in cell C3:
The first cell B3 contains 1 and the HEX2BIN function returns 1 in cell D3, the second cell B4 contains F and the HEX2BIN function returns 1111 in cell D4.
4. How is hexadecimal to binary calculated?
Binary | 0 | 1 | 10 | 11 | 100 | 101 | 110 | 111 | 1000 | 1001 | 1010 | 1011 | 1100 | 1101 | 1110 | 1111 |
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 |
Convert every hexadecimal to a binary using the table above.
4.1 Example 1
Hexadecimal value 664 is calculated to a binary like this:
Third hexadecimal value: 6 = 0110
Second hexadecimal value: 6 = 0110
First hexadecimal value: 4 = 0100
equals
0110 0110 0100
4.2 Example 2
Hexadecimal value F9F is calculated to binary like this:
F = 1111
9 = 1001
F = 1111
equals
1111 1001 1111
5. HEX2BIN Function not working
HEX2BIN returns the #NUM! error value if
- Number is less than FFFFFFFE00 or larger than 1FF. See cells B3 and C3 in the image above.
- [places] is negative. See the formula next to cell C5.
- it requires more than the specified places characters. See the formula next to cell C6.
- The number is not a valid base 16 number. See cells B4 and C4 in the image above.
HEX2BIN returns the #VALUE! error if
- [places] is not a number. See the formula next to cell C7.
The second argument [places]is truncated if it is not an integer. For example, [places] is 4.1111111111 and the HEX2BIN function truncates it to 4. See the formula next to cell C8.
HEX2BIN ignores places and returns a 10-character binary number if the hexadecimal number is negative.
Useful links
HEX2BIN function - Microsoft
Hex to Binary converter
Hexadecimal - Wikipedia
'' function examples
The following article has a formula that contains the function.
Table of Contents How to use the DEC2BIN function How to use the DEC2HEX function How to use the DEC2OCT […]
Functions in 'Engineering' category
The HEX2BIN function function is one of 42 functions in the 'Engineering' category.
How to comment
How to add a formula to your comment
<code>Insert your formula here.</code>
Convert less than and larger than signs
Use html character entities instead of less than and larger than signs.
< becomes < and > becomes >
How to add VBA code to your comment
[vb 1="vbnet" language=","]
Put your VBA code here.
[/vb]
How to add a picture to your comment:
Upload picture to postimage.org or imgur
Paste image link to your comment.
Contact Oscar
You can contact me through this contact form