Hex2Dec


Description

Convert a string representation of a hexadecimal number to decimal. Input is limited to the range of 0 to 800000000000, where 0 to 7FFFFFFFFFFF is treated as positive and 800000000000 to FFFFFFFFFFFF is treated as negative.

Beginning with Origin 2019, the "0x" prefix is supported (see Examples). Additionally, Origin worksheets and matrices now support display of hexadecimal numbers.

Syntax

int Hex2Dec(string str$)

Parameters

str$

The string of hexadecimal to convert to decimal.

Return

Return the decimal of the specified hexadecimal.

Example

hex2Dec(2B) = ;  // 43

string strHex$ = FE4;
int n = hex2Dec(strHex$);
n = ;  // 4068
aa$=0x12312340002;
Hex2Dec(aa$)=; // prefix "0x"
bb$=12312340002;
Hex2Dec(bb$)=; // no prefix "0x"
Hex2Dec(aa$)=1250140880898
Hex2Dec(bb$)=1250140880898

See Also

Bin2Dec, Dec2Bin, Dec2Hex