Login     Register

        Contact Us     Search

XLeratorDB/engineering Online Documentation

SQL Server HEX2DEC function


 
Updated: 27 August 2010

Use HEX2DEC to convert a hexadecimal number to decimal.
Syntax
SELECT [wctEngineering].[wct].[HEX2DEC] (
   <@Number, nvarchar(4000),>)
Arguments
@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 Types
float
Remarks
·         If @Number is not a valid hexadecimal number, HEX2DEC returns an error.
Examples

select
wct.HEX2DEC('A5')

This produces the following result
----------------------
165
 
(1 row(s) affected)


select
wct.HEX2DEC('FFFFFFFF5B')

This produces the following result
----------------------
-165
 
(1 row(s) affected)


select
wct.HEX2DEC('3DA408B9')

This produces the following result
----------------------
1034160313
 
(1 row(s) affected)


Copyright 2008-2017 Westclintech LLC         Privacy Policy        Terms of Service