HEX2DEC Function

Excel 2007+

Summary

The Excel HEX2DEC function converts hexadecimal numbers to their decimal equivalents, supporting both positive and negative values through two's complement notation. Perfect for binary data analysis, programming conversions, and engineering calculations.

Syntax

HEX2DEC(number)

Parameters

Parameter Type Required Description
number Text Yes Hexadecimal number to convert (max 10 characters, 40 bits). Most significant bit is sign bit; remaining bits represent magnitude. Uses two's complement for negatives.

Using the HEX2DEC Function

HEX2DEC is invaluable when working with hexadecimal data from programming, memory dumps, color codes, or binary file analysis. It handles the full 40-bit range including negative values represented in two's complement format.

Common HEX2DEC Examples

Basic Positive Hex Conversion

=HEX2DEC("A5")

Converts hexadecimal A5 (165 in decimal) to its decimal equivalent.

Negative Hex Number (Two's Complement)

=HEX2DEC("FFFFFFFF5B")

Converts 40-bit two's complement hex FFFFFFFF5B to decimal -165.

Large Positive Hex Value

=HEX2DEC("3DA408B9")

Converts large hexadecimal 3DA408B9 to decimal 1,034,000,889.

Frequently Asked Questions

HEX2DEC returns #NUM! error for numbers longer than 10 hexadecimal characters (40 bits).

Negative numbers use two's complement notation where the most significant bit (leftmost) is the sign bit.

Yes, HEX2DEC accepts both uppercase (A-F) and lowercase (a-f) hexadecimal digits.

Common Errors and Solutions

#NUM!

Cause: Invalid hexadecimal characters or number exceeds 10 characters

Solution: Verify input contains only 0-9 and A-F (a-f), and is ≤10 characters long

#VALUE!

Cause: Non-text input provided

Solution: Ensure the number parameter is enclosed in quotes if it's a text string

Notes

  • Maximum 10 hex characters = 40 bits total
  • Most significant bit (40th bit) is sign bit
  • Uses standard two's complement for negative representation
  • Scientific notation may display for very large results

Compatibility

Available in: Excel 2007, Excel 2010, Excel 2013, Excel 2016, Excel 2019, Excel 2021, Microsoft 365

Not available in: Excel 2003 and earlier

Content last reviewed: December 9, 2025
Update frequency: As needed
Excel versions tested: Excel 2007+