See also: binToDec, octToDec

Converts a hexadecimal number string to an integer.

Syntax

JSV_hexToDec(expH)

Prototype

expH.hexToDec()

Returns

The hexToDec function returns the decimal number of the hexadecimal number string.

Parameters

The hexToDec function uses the following arguments.

Argument Description
expH The hexadecimal number string that is to be converted to a decimal.

Remarks

There is no checking whether expH is a hexadecimal string. Users of this function should check that the value of expH is a valid argument to this function.

Uses the parseInt function to return an integer representing the specified binary string. If the first character cannot be converted to a number, parseInt returns NaN.

Dependencies

n/a

Example

The following lines of code

var f = "10E6";
document.write( "The number " + f + " is decimal " + JSV_hexToDec(f) );
f = "A2C4";
document.write( "The number " + f + " is decimal " + JSV_hexToDec(f) );

produce