'asp将二进制转十进制,使用方法:cDec(11010)
function cDec(num)
cDecstr=0
if len(num)>0 and isnumeric(num) then
for inum=0 to len(num)-1
cDecstr=cDecstr+2^inum*cint(mid(num,len(num)-inum,1))
next
end if
cDec=cDecstr
end function
'asp将二进制转十进制,使用方法:cDec(11010)
function cDec(num)
cDecstr=0
if len(num)>0 and isnumeric(num) then
for inum=0 to len(num)-1
cDecstr=cDecstr+2^inum*cint(mid(num,len(num)-inum,1))
next
end if
cDec=cDecstr
end function
'asp将十进制转二进制,使用方法:cBit(26)
function cBit(num)
cBitstr=""
if len(num)>0 and isnumeric(num) then
do while not num \ 2 < 1
cBitstr=(num mod 2) &cBitstr
num=num \ 2
loop
end if
cbit=num&cBitstr
end function
'asp将十六进制转二进制,使用方法:HcB(26)
function HcB(num)
if len(num)>0 then
HcBstr=""
for i=1 to len(num)
select case (mid(num,i,1))
case "0" HcBstr=HcBstr&"0000"
case "1" HcBstr=HcBstr&"0001"
case "2" HcBstr=HcBstr&"0010"
case "3" HcBstr=HcBstr&"0011"
case "4" HcBstr=HcBstr&"0100"
case "5" HcBstr=HcBstr&"0101"
case "6" HcBstr=HcBstr&"0110"
case "7" HcBstr=HcBstr&"0111"
case "8" HcBstr=HcBstr&"1000"
case "9" HcBstr=HcBstr&"1001"
case "A" HcBstr=HcBstr&"1010"
case "B" HcBstr=HcBstr&"1011"
case "C" HcBstr=HcBstr&"1100"
case "D" HcBstr=HcBstr&"1101"
case "E" HcBstr=HcBstr&"1110"
case "F" HcBstr=HcBstr&"1111"
end select
next
end if
HcB=HcBstr
end function
'十进制转十六进制 Hex(num)
function HcO(num)'十六进制转八进制
HcO=Oct(HcD(num))
end function
'十进制转八进制 Oct(num)
function HcD(num)'十六进制转十进制
HcD=cDec(HcB(num))
end function
%>