Login     Register

        Contact Us     Search

XLeratorDB/engineering Online Documentation

SQL Server BIN2DEC function


 
Updated: 27 August 2010

Use BIN2DEC to convert a binary number to a decimal.
 
Syntax
SELECT [wctEngineering].[wct].[BIN2DEC] (
   <@Number, nvarchar(4000),>)
Arguments
@Number
is the value at which to evaluate the function. The most significant bit of number is the sign bit. The remaining 9 bits are magnitude bits. Negative numbers are represented using two's-complement notation.@Number is an expression of type varchar or of a type that can be implicitly converted to varchar and must contain only zeros (0) or ones (1).
Return Types
float
Remarks
·         If @Number is not a valid binary number, or if @Number contains more than 10 characters (10 bits), BIN2DEC returns an error.
Examples

select
wct.BIN2DEC('1000000000')

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


select
wct.BIN2DEC('111111111')

This produces the following result

----------------------
511
 
(1 row(s) affected)


Copyright 2008-2024 Westclintech LLC         Privacy Policy        Terms of Service