The Excel Hex2Dec function converts a hexadecimal (a base-16 number) into a decimal number.
Syntax: =HEX2DEC (number)
The HEX2DEC function syntax has the following arguments:
- Number : Required. The hexadecimal number you want to convert. Number cannot contain more than 10 characters (40 bits). The most significant bit of number is the sign bit. The remaining 39 bits are magnitude bits. Negative numbers are represented using two’s-complement notation.
Example: Let’s look at some Excel HEX2DEC function examples and explore how to use the HEX2DEC function as a worksheet function in Microsoft Excel:
Syntax: =HEX2DEC(A2)
Result:
Based on the Excel spreadsheet above, the following HEX2DEC examples would return:
Syntax: =HEX2DEC(A3)
Result: 15
Syntax: =HEX2DEC(A4)
Result: 1
Syntax: =HEX2DEC(A5)
Result: 0
Syntax: =HEX2DEC(A6)
Result: 1034160313
Syntax: =HEX2DEC(A7)
Result: -1
Syntax: =HEX2DEC(A8)
Result: -165
Syntax: =HEX2DEC(A9)
Result: 165
Syntax: =HEX2DEC(A10)
Result: 29
Syntax: =HEX2DEC(A11)
Result: 41805
Syntax: =HEX2DEC(A12)
Result: 273
Syntax: =HEX2DEC(A13)
Result: 31
Note:
- The number argument can have up to 10 characters (40 bits). The sign bit is the most significant bit of the number. The other 39 bits are used as magnitude bits. Excel represents negative numbers using two’s-complement notation.
- The HEX2DEC function returns a #NUM! error if the number is not a hexadecimal number.
- The function returns a #NUM! error if the number resembles >=3^23.