Documentation/Calc Functions/HEX2DEC

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:
 * Hexadecimal
 * Two's complement

Related LibreOffice functions:
HEX2BIN

HEX2OCT

ODF standard:
Section 6.19.12, part 2

Equivalent Excel functions:
HEX2DEC