SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
create function dec_to_oct(@v_dec int)
returns nvarchar(64)
as
begin
declare @v_oct nvarchar(1)
declare @v_oct_final nvarchar(64)
declare @v_temp int
declare @v_mid int
set @v_oct=''
set @v_temp=0
set @v_oct_final=''
while(@v_dec<>0)
begin
set @v_temp=@v_dec%8
set @v_mid=@v_dec/8
set @v_oct=@v_temp
set @v_oct_final=@v_oct+@v_oct_final
set @v_dec=@v_mid
end
return @v_oct_final
end
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
create function dec_to_hex(@v_dec int)
returns nvarchar(64)
as
begin
declare @v_hex nvarchar(1)
declare @v_hex_temp int
declare @v_hex_final nvarchar(64)
declare @v_temp nvarchar(1)
declare @v_mid int
set @v_hex=''
set @v_temp=0
set @v_hex_final=''
while(@v_dec<>0)
begin
set @v_hex_temp=@v_dec%16
set @v_mid=@v_dec/16
IF @v_hex_temp=15 SET @v_temp='F'
ELSE IF @v_hex_temp=14 SET @v_temp='E'
ELSE IF @v_hex_temp=13 SET @v_temp='D'
ELSE IF @v_hex_temp=12 SET @v_temp='C'
ELSE IF @v_hex_temp=11 SET @v_temp='B'
ELSE IF @v_hex_temp=10 SET @v_temp='A'
ELSE SET @v_temp=@v_hex_temp
set @v_hex=@v_temp
set @v_hex_final=@v_hex+@v_hex_final
set @v_dec=@v_mid
end
return @v_hex_final
end
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
create function dec_to_bin(@v_dec int)
returns nvarchar(64)
as
begin
declare @v_bin nvarchar(1)
declare @v_bin_final nvarchar(64)
declare @v_temp int
declare @v_mid int
set @v_bin=''
set @v_temp=0
set @v_bin_final=''
while(@v_dec<>0)
begin
set @v_temp=@v_dec%2
set @v_mid=@v_dec/2
set @v_bin=@v_temp
set @v_bin_final=@v_bin+@v_bin_final
set @v_dec=@v_mid
end
return @v_bin_final
end
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
阅读(901) | 评论(0) | 转发(0) |