Rem Infite multiplication precision algorithm http://en.wikipedia.org/wiki/Infinite_precision_arithmetic

max=10

p=2*max+2

graphsize 600,600

font "arial", 8,100

Dim n1(max+1)

Dim n2(max+1)

Dim Prod(p)

Rem {units ,tens ,hundreds ,etc }

n1={2,9,7,5,6,4,3,4,3,4}

n2={9,9,3,4,5,2,4,3,4,3}

Rem Multiplication

for y = 0 to max

for x = 0 to max

Prod[x+y]=Prod[x+y]+n1[x]*n2[y]

next x

next y

Rem Carying

for x = 0 to p-2

While Prod[x]>9

Prod[x]=Prod[x]-10

Prod[x+1]=Prod[x+1]+1

end While

next x

Rem Printing

for x = 0 to max

print n1[max-x];

next x

Print" x ";

for x = 0 to max

print n2[max-x];

next x

Print" = ";

p=p-1

for x = 0 to p

Print Prod[p-x];

next x

## Monday, December 13, 2010

Subscribe to:
Post Comments (Atom)

## No comments:

## Post a Comment