日期:2014-05-20 浏览次数:20891 次
Public Function BigNumberMul(ByVal Mul1 As String, ByVal Mul2 As String) As String '支持小数相乘。也支持负数
Dim mul11 As String = ""
Dim mul12 As String = ""
Dim mul21 As String = ""
Dim mul22 As String = ""
Dim t As Boolean = False
Dim i As Integer
Dim is2(1) As Boolean
If Mul1 = "" Or Mul2 = "" Or BigGetNumber(Mul1, mul11, mul12, is2(0)) = False Or BigGetNumber(Mul2, mul21, mul22, is2(1)) = False Then
Return ""
End If
i = mul12.Length - mul22.Length
If i > 0 Then
mul22 += StrDup(i, "0")
Else
mul12 += StrDup(-i, "0")
End If
i = mul22.Length * 2
mul11 = BigNumberMul_(mul11 + mul12, mul21 + mul22)
Dim j As Integer = i - mul11.Length + 1
If j > 0 Then
mul11 = StrDup(j, "0") + mul11
End If
If i > 0 Then
mul22 = Mid(mul11, mul11.Length - i + 1, i)
mul11 = Mid(mul11, 1, mul11.Length - i)
i = mul22.Length
While mul22.EndsWith("0")
i -= 1
mul22 = Mid(mul22, 1, i)
End While
If i > 0 Then
mul11 += "." + mul22
End If
End If
If is2(1) <> is2(0) Then
mul11 = "-" + mul11
End If
Return mul11
End Function
Public Function BigNumberMul_(ByVal Mul1 As String, ByVal Mul2 As String) As String '正整数相乘
Dim size1 As Integer = Mul1.Length
Dim size2 As Integer = Mul2.Length
Dim Mulret As String = ""
Dim i As Integer = size1 - size2
If i < 0 Then
Mulret = Mul1
Mul1 = Mul2
Mul2 = Mulret
i = size1