Documentation/Calc Functions/HEX2DEC
TDF LibreOffice Document Liberation Project Community Blogs Weblate Nextcloud Redmine Ask LibreOffice Donate
Function name:
HEX2DEC
Category:
Add-in
Summary:
Converts a hexadecimal number (base-16) to its decimal (base-10) equivalent. The input hexadecimal number must correspond to a decimal number d in the range -239 ≤ d < 239.
Syntax:
HEX2DEC(Number)
Returns:
Returns an integer number in the range -239 ≤ d < 239, which is the decimal value that corresponds to the specified hexadecimal number.
Arguments:
Number is a string or a number, or a reference to a cell containing one of those types, which gives the hexadecimal number that is to be converted to decimal. The hexadecimal number must comprise no more than 10 characters and should correspond to a decimal number in the range -239 ≤ d < 239. If the hexadecimal number contains any letters (a…f or A…F; the case of these characters is not significant), it must either be in a referenced cell or passed as a string argument in quotation marks.
- Number should use the standard two's complement representation, so that positive numbers are hexadecimal 0 to 7FFFFFFFF (0 to 239-1 decimal) and negative numbers are hexadecimal FFFFFFFFFF to 8000000000 (-1 to -239 decimal). Negative numbers must be ten characters long with the leftmost bit set to 1; positive numbers can comprise less than 10 characters.
- If Number does not specify a valid hexadecimal number, then HEX2DEC reports an invalid argument error (Err:502). This may arise, for example, if Number contains more than 10 characters or if it contains any character other than 0…9, a…f, or A…F.
- If a hexadecimal value containing one or more letters is passed directly to the function and is not surrounded by quotation marks, HEX2DEC reports a #NAME? error.
- If Number is a string comprising no characters, or a reference to an empty cell, HEX2DEC returns 0.
- Although the content of Number may appear to be decimal if it contains no letters, HEX2DEC will interpret it correctly.
Additional details:
The following Wikipedia pages provide useful background information that is relevant to this function:
Examples:
Formula | Description | Returns |
---|---|---|
=HEX2DEC("3F") | Here the function converts the hexadecimal value of 3F (passed as a string) to its decimal equivalent of 63. | 63 |
=HEX2DEC(3F) | Here the function returns an invalid name error because Calc does not recognize 3F as a number. | #NAME? |
=HEX2DEC(15) | Here the function converts the hexadecimal value of 15 (passed as a number) to its decimal equivalent of 21. | 21 |
=HEX2DEC(D1) where cell D1 contains 3f (text). | Here the function again converts the hexadecimal value of 3F (passed via a cell reference) to its decimal equivalent of 63. | 63 |
=HEX2DEC("8000000000") | Here the function converts the minimum allowed 10-character hexadecimal value of 8000000000 to its decimal equivalent of -549755813888 (equal to -239). | −549755813888 |
=HEX2DEC("FFFFFFFFFF") | Here the function converts the 10-character hexadecimal value of FFFFFFFFFF to its decimal equivalent of -1. | −1 |
=HEX2DEC("7fffffffff") | Here the function converts the maximum allowed hexadecimal value of 7FFFFFFFFF to its decimal equivalent of 549755813887 (equal to 239-1). | 549755813887 |
Related LibreOffice functions:
ODF standard:
Related (or similar) Excel functions:
HEX2DEC