根据0~20的与运算总结
0~20与运算
根据0~20的与运算总结以下几点规则:
经观察后面的规则难以总结,如有答案请留言给我.谢谢!
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 Create FUNCTION DecToBin(@Dec Int) 2 RETURNS VARCHAR(16) 3 AS 4 begin 5 declare @BinStr as varchar(20) 6 declare @Mod2 as int 7 declare @Div2 as int 8 9 10 11 set @Div2 = @Dec / 2 12 set @Mod2 = @Dec % 2 13 set @BinStr='' 14 15 16 17 while @Div2<>0 18 begin 19 if @Mod2=0 20 set @BinStr = @BinStr + '0' 21 else 22 set @BinStr = @BinStr + '1' 23 24 set @Dec = @Dec / 2 25 set @Div2 = @Dec / 2 26 set @Mod2 = @Dec % 2 27 end 28 29 set @BinStr = @BinStr + '1' 30 31 return REVERSE(@BinStr + right('0000000000000000',16-len(@BinStr))) 32 end
立刻行动,坚持不懈,不断学习!