SQL Server 二进制转为十进制
2012-08-31 12:04
218 查看
CREATE FUNCTION BinaryToDec (@BinaryChar char(10)) RETURNS int AS BEGIN DECLARE @stringLength int,@ReturnValue int,@Index int DECLARE @CurrentChar char(1) SET @Index = 0 SET @ReturnValue = 0 SET @stringLength = LEN(@BinaryChar) While @Index<@stringLength BEGIN SET @Index = @Index + 1 SET @CurrentChar = SUBSTRING(@BinaryChar,@Index,1) IF(@CurrentChar='1' or @CurrentChar='0') BEGIN SET @ReturnValue = @ReturnValue + (CAST(@CurrentChar as int) * POWER(2,@stringLength - @Index)) END END RETURN @ReturnValue END
相关文章推荐
- java中十进制转为二进制源码
- 位运算实例(二):十进制转为二进制
- C/C++:十进制转为二进制(n进制转为十进制)
- [SQL Server] 十进制转换为二进制——函数
- 十进制转为二进制以及二进制转为十进制算法
- 十进制转为二进制
- 位操作+递归 (十进制转为二进制)
- 十进制小数转为二进制
- 十进制0到16转为二进制
- C语言——十进制转为二进制、八进制、十六进制的函数转换
- 15电气二班徐立立(十进制转为二进制)
- 十进制转为二进制
- 十进制转为二进制
- 十进制转为二进制
- java 二进制转为十进制,十进制转为二进制
- 十进制小数转为二进制
- 十进制的正整数,负数, 小数转为二进制.八进制.十六进制的方法 包括原码,反码,补码的介绍
- 把十进制转为二进制到16进制
- 二进制转为十进制,十进制转为二进制
- 十进制小数转为二进制小数