十进制转换为二进制
ASP 2008/2/14 8:05:34 点击:不统计
关键词:十进制转换为二进制,十进制二进制转换,十进制,二进制
function c10to2(x)
mysign=sgn(x)
x=abs(x)
DigS=1
do
if x<2^DigS then
exit do
else
DigS=DigS+1
end if
loop
tempnum=x
i=0
for i=DigS to 1 step-1
if tempnum>=2^(i-1) then
tempnum=tempnum-2^(i-1)
c10to2=c10to2 & "1"
else
c10to2=c10to2 & "0"
end if
next
if mysign=-1 then c10to2="-" & c10to2
end function
·上一篇:十六进制转换为二进制 >> ·下一篇:asp常用函数 >>