BIN2DEC
Updated 2023-11-08 15:53:30.593000
Syntax
SELECT [westclintech].[wct].[BIN2DEC] (
<@Number, nvarchar(4000),>)
Description
Use the scalar function BIN2DEC to convert a binary number to a decimal.
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 Type
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.
{"columns":[{"field":"column 1","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"column 1":"-512"}]}
select wct.BIN2DEC('111111111');
This produces the following result.
{"columns":[{"field":"column 1","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"column 1":"511"}]}