肯请csdn的高手帮忙
<%
'十进制转任意进制
'n = 数字
'x = 进制,最大63进制
Public Function BaseX(ByVal n, ByVal x)
Dim t, m
If n <> 0 Then
t = t & BaseX(n \ x, x)
m = n Mod x
If m < 10 Then
t = t & m
Else
t = t & Chr(m + 65 - 10)
End If
End If
BaseX = t
End Function
'任意进制转十进制
's = 进制字符串
'x = 进制
Public Function ConvertX(ByVal s, ByVal x)
Dim i, l
Dim t, p
Dim u
l = Len(s)
t = 0
p = 1
For i = l To 1 Step -1
u = Asc(Mid(s, i, 1)) And &HFF
If u > = 48 And u <= 57 Then
u = u - 48
ElseIf u > = 65 And u <= 90 Then
u = u - 65 + 10
ElseIf u > = 97 And u <= 122 Then
u = u - 97 + 10
End If
t = t + u * p
p = p * x
Next
ConvertX = t
End Function
Dim s
s = BaseX(1200, 36)
Response.Write s & " <br/> "
Response.Write ConvertX(s, 36) & " <br/> "
%>
当s= BaseX(1200, 36)里面的取值比较小的时候程序完全正确,
当把s= BaseX(1200, 36)改为s= BaseX(22399684340, 36)甚至数值更大的时候就会出现溢出,把n改问CDbl型还是不能解决问题
------解决方案--------------------路过,帮顶