这个也是写着是分治法乘法,不知道是不是,不知道怎么用?咋弄?
Function Mult_() '分治法 多位数相乘 C*A=C,A 2013-06.14
Dim myVar, myNum, Var, r As Variant
Dim Aa, Ba, Ca, xP2 As Single
Dim Dx As Chen
Dim ax_sz(512), bx_sz(512), cx_sz(512) As Variant
Ax.St = Ax.St + Zero
Cx.St = Cx.St + Zero
If Left(Ax.St, 1) > "0" And Left(Cx.St, 1) > "0" Then
For i = 0 To xP
ax_sz(i) = CDec(Mid(Ax.St, i * Gsw + 1, Gsw))
bx_sz(i) = CDec(Mid(Cx.St, i * Gsw + 1, Gsw))
Next i
myVar = ax_sz(0) * bx_sz(0)
cx_sz(1) = myVar
For i = 1 To xP
myNum = ax_sz(i) * bx_sz(i)
myVar = myVar + myNum
For j = 0 To (i - 1) / 2
cx_sz(i + 1) = cx_sz(i + 1) + (ax_sz(i - j) - ax_sz(j)) * (bx_sz(j) - bx_sz(i - j))
Next
cx_sz(i + 1) = cx_sz(i + 1) + myVar
Next
r = CDec(0)
For i = xP To 0 Step -1
cx_sz(i) = cx_sz(i) + r
r = Fix(cx_sz(i) / Zero6)
cx_sz(i) = cx_sz(i) - r * Zero6
Next i
oResult = CStr(cx_sz(0))
For i = 1 To xP
oResult = oResult + Right(Zero06 + CStr(cx_sz(i)), Gsw)
Next i
Dx.Bz = IIf(Ax.Bz = Cx.Bz, "", "-")
Dx.St = oResult
'指数计算
Aa = Val(Left(Ax.St, 1))
Ba = Val(Left(Cx.St, 1))
Ca = Val(Left(Dx.St, 1))
If Ax.Zs + Cx.Zs < 10 ^ 15 Then
Dx.Zs = Ax.Zs + Cx.Zs + IIf(Aa * Ba <= Ca, 0, 1)
Else
Dx.Zs = 0
End If
Cx = Dx
Ax = Dx
Else
Ax.Bz = ""
Ax.St = "0"
Ax.Zs = 0
Cx = Ax
End If
End Function
Function Mult_() '分治法 多位数相乘 C*A=C,A 2013-06.14
Dim myVar, myNum, Var, r As Variant
Dim Aa, Ba, Ca, xP2 As Single
Dim Dx As Chen
Dim ax_sz(512), bx_sz(512), cx_sz(512) As Variant
Ax.St = Ax.St + Zero
Cx.St = Cx.St + Zero
If Left(Ax.St, 1) > "0" And Left(Cx.St, 1) > "0" Then
For i = 0 To xP
ax_sz(i) = CDec(Mid(Ax.St, i * Gsw + 1, Gsw))
bx_sz(i) = CDec(Mid(Cx.St, i * Gsw + 1, Gsw))
Next i
myVar = ax_sz(0) * bx_sz(0)
cx_sz(1) = myVar
For i = 1 To xP
myNum = ax_sz(i) * bx_sz(i)
myVar = myVar + myNum
For j = 0 To (i - 1) / 2
cx_sz(i + 1) = cx_sz(i + 1) + (ax_sz(i - j) - ax_sz(j)) * (bx_sz(j) - bx_sz(i - j))
Next
cx_sz(i + 1) = cx_sz(i + 1) + myVar
Next
r = CDec(0)
For i = xP To 0 Step -1
cx_sz(i) = cx_sz(i) + r
r = Fix(cx_sz(i) / Zero6)
cx_sz(i) = cx_sz(i) - r * Zero6
Next i
oResult = CStr(cx_sz(0))
For i = 1 To xP
oResult = oResult + Right(Zero06 + CStr(cx_sz(i)), Gsw)
Next i
Dx.Bz = IIf(Ax.Bz = Cx.Bz, "", "-")
Dx.St = oResult
'指数计算
Aa = Val(Left(Ax.St, 1))
Ba = Val(Left(Cx.St, 1))
Ca = Val(Left(Dx.St, 1))
If Ax.Zs + Cx.Zs < 10 ^ 15 Then
Dx.Zs = Ax.Zs + Cx.Zs + IIf(Aa * Ba <= Ca, 0, 1)
Else
Dx.Zs = 0
End If
Cx = Dx
Ax = Dx
Else
Ax.Bz = ""
Ax.St = "0"
Ax.Zs = 0
Cx = Ax
End If
End Function