and I thought wow that's a great method to teach.
a vid of the method here
http://www.youtube.com/watch?v=zPmrKtIhf_I
and a quick and dirty bit of code to do the same no idea what it's limits are.
Code: Select all
EnableExplicit
Procedure.s jmul(sa.s,sb.s)
Protected lenA,lenb ,lenC,a,b,c,ct,v,r,sout.s
lenA = Len(sa)
lenB = Len(sb)
lenC =(lenA+lenB)-1
Dim mat(LenA,lenB)
Dim sum((lenA*lenB)-1)
For a = 1 To lenA
For b = 1 To lenB
mat(a,b) = Val(Mid(sa,a,1)) * Val(Mid(sb,b,1))
If a > 1 And b < lenb
mat(a,b) + mat(a-1,b+1)
EndIf
Next
sum(a) = mat(a,1)
Next
ct = lenA+1
For c = 2 To lenB
sum(ct) = mat(lenA,c)
ct+1
Next
For c = lenc To 1 Step-1
v = sum(c) % 10
r =( sum(c) - v ) / 10
sum(c) = v
sum(c-1)+r
Next
For c = 1 To lenc
sout + Str(sum(c))
Next
ProcedureReturn sout
EndProcedure
MessageRequester ("Japanese Multiplication",jmul("10000000000000000000000000000000","10000000000000000000000000000000"))



