Logo

HEX2DEC

Updated 2023-11-08 16:12:10.760000

Syntax

SELECT [westclintech].[wct].[HEX2DEC] (
   <@Number, nvarchar(4000),>)

Description

Use the scalar function HEX2DEC to convert a hexadecimal number to decimal.

Arguments

@Number

@Number is the hexadecimal number you want to convert. @Number cannot contain more than 10 characters. The most significant bit of @Number is the sign bit (40th bit from the right). The remaining 39 bits are magnitude bits. Negative numbers are represented using two's-complement notation. @Number is an expression of type float or of a type that can be implicitly converted to float.

Return Type

float

Remarks

If @Number is not a valid hexadecimal number, HEX2DEC returns an error.

Examples

select wct.HEX2DEC('A5');

This produces the following result.

{"columns":[{"field":"column 1","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"column 1":"165"}]}
select wct.HEX2DEC('FFFFFFFF5B');

This produces the following result.

{"columns":[{"field":"column 1","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"column 1":"-165"}]}
select wct.HEX2DEC('3DA408B9');

This produces the following result.

{"columns":[{"field":"column 1","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"column 1":"1034160313"}]}