日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

ASP常用进制转化类(2,8,10,16,32,64)

發(fā)布時(shí)間:2025/5/22 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ASP常用进制转化类(2,8,10,16,32,64) 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
<% ' 名稱:HDOBTools ' 描述:進(jìn)制轉(zhuǎn)化類 ' 作用:用于各種進(jìn)轉(zhuǎn)的轉(zhuǎn)化 Class HDOBToolsPrivate hdobHackPrivate Sub Class_Initialize()Set hdobHack = New HDOBTools_HackEnd SubPrivate Sub Class_Terminate()Set hdobHack = NothingEnd Sub' 十進(jìn)制轉(zhuǎn)二進(jìn)制Function Bit(num)Bit = Dec2Other(num,2)End Function' 十進(jìn)制轉(zhuǎn)八進(jìn)制' 此函數(shù)其實(shí)不必添加,只是為了補(bǔ)全,所以需借助附加類Function [Oct](num)[Oct] = hdobHack.dec2oct(num)End Function' 十進(jìn)制轉(zhuǎn)十六進(jìn)制' 此函數(shù)其實(shí)不必添加,只是為了補(bǔ)全,所以需借助附加類Function [Hex](num)[Hex] = hdobHack.dec2hex(num)End Function' 十進(jìn)制轉(zhuǎn)三十二進(jìn)制' 自我擴(kuò)展的:Str16_31 = "GHIJKLMNOPQRSTUV"Function Ext32(num)Ext32 = Dec2Other(num,32)End Function' 十進(jìn)制轉(zhuǎn)六十四進(jìn)制' 自我擴(kuò)展的:Str16_31 = "GHIJKLMNOPQRSTUV"' 自我擴(kuò)展的:Str32_63 = "WXYZ+=abcdefghijklmnopqrstuvwxyz"Function Ext64(num)Ext64 = Dec2Other(num,64)End Function' 二進(jìn)制轉(zhuǎn)十進(jìn)制Function Bit2Dec(num)Bit2Dec = Other2Dec(num,2)End Function' 八進(jìn)制轉(zhuǎn)十進(jìn)制Function Oct2Dec(num)Oct2Dec = Other2Dec(num,8)End Function' 十六進(jìn)制轉(zhuǎn)十進(jìn)制Function Hex2Dec(num)Hex2Dec = Other2Dec(num,16)End Function' 各種進(jìn)制的轉(zhuǎn)化Function Other2Other(num,x1,x2)If x1=x2 Then Other2Other = num : Exit FunctionIf x1 = 10 ThenOther2Other = Dec2Other(num,x2)ElseIf x2 = 10 ThenOther2Other = Other2Dec(num,x1) ElseOther2Other = Dec2Other(Other2Dec(num,x1),x2)End IfEnd Function' 十進(jìn)制轉(zhuǎn)x(x=2,8,16,32,64)進(jìn)制' 結(jié)果為字符串' 注:對于2,8進(jìn)制,結(jié)果為(全)數(shù)字字符串,對于16以上進(jìn)制,結(jié)果不一定為數(shù)字字符串Function Dec2Other(num,x)'對于十進(jìn)制轉(zhuǎn)8或16進(jìn)制,有專門的內(nèi)置函數(shù)可用(當(dāng)然,也可按常規(guī)轉(zhuǎn)化)If x = 8 ThenDec2Other = Oct(num) : Exit FunctionElseIf x = 16 ThenDec2Other = Hex(num) : Exit FunctionEnd If'Dim Str16_31 : Str16_31 = "GHIJKLMNOPQRSTUV" '32位'Dim Str32_63 : Str32_63 = "WXYZ+=abcdefghijklmnopqrstuvwxyz" '64位Dim strBit : strBit = EmptyDim tmpDo tmp = (num Mod x)If tmp = 36 Thentmp = "+"ElseIf tmp = 37 Thentmp = "="ElseIf tmp > 37 Then 'a(97-->38)tmp = Chr(97+tmp-37-1)ElseIf tmp > 9 Then tmp = Chr(65+tmp-9-1)End IfstrBit= tmp & strBitnum=num \ xLoop While Not num <= xIf num = 36 Thennum = "+"ElseIf num = 37 Thennum = "="ElseIf num > 37 Thennum = Chr(97+num-37-1)ElseIf num > 9 Then num = Chr(65+num-9-1)End IfDec2Other=num&strBitDo While Instr(Dec2Other,"0") = 1Dec2Other = Mid(Dec2Other,2,Len(Dec2Other))LoopEnd Function' x(x=2,8,16,32,64)進(jìn)制轉(zhuǎn)十進(jìn)制' 結(jié)果為整型數(shù)字Function Other2Dec(num,x)Dim tmpDim cDecNumber : cDecNumber=0For inum=0 to len(num)-1tmp = mid(num,len(num)-inum,1)If Not isNumeric(tmp) ThenIf tmp = "+" Thentmp = 36ElseIF tmp = "=" Thentmp = 37ElseIf asc(tmp) > 97 Thentmp = (asc(tmp)-97+37+1)ElseIf asc(tmp) > 65 Thentmp = (asc(tmp)-65+9+1)End IfElsetmp = Int(tmp)End IfcDecNumber=cDecNumber + x ^ inum * tmpNextOther2Dec=cDecNumberEnd Function End Class' 附加類,用于防止與同名內(nèi)置函數(shù)的沖突導(dǎo)致的堆棧溢出 ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Class HDOBTools_HackFunction Dec2Oct(num)Dec2Oct = Oct(num)End FunctionFunction Dec2Hex(num)Dec2Hex = Hex(num)End Function End Class ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ %>

?

轉(zhuǎn)載于:https://www.cnblogs.com/dreamyoung/archive/2012/09/28/2706779.html

總結(jié)

以上是生活随笔為你收集整理的ASP常用进制转化类(2,8,10,16,32,64)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。