08-16-2003, 07:44 AM
If v is my array then the number it represent is
x = v(0) + v(1) * base ^ -1 + v(2) * base ^ -2...
v(0) is the integer part and so on ...
if base is 65536 we use the full integer, if base is 10000 each element of the array uses the numbers in the range 0-9999.
Then add to elements the same way as you do with string:
If you wanna to add v and u then
To multiply by a number k (integer) then
This is from a project to calculate pi, that why v(0) is the integer part but you can change it.
And the error is not as simply as you say. If you have to add 1000 number, and each one have an error of 1D-50 the error at most will be 1000 * 1D-50. Now what i you have to add an infinite amount of numbers?
x = v(0) + v(1) * base ^ -1 + v(2) * base ^ -2...
v(0) is the integer part and so on ...
if base is 65536 we use the full integer, if base is 10000 each element of the array uses the numbers in the range 0-9999.
Then add to elements the same way as you do with string:
If you wanna to add v and u then
Code:
c = 0
for i = ubound(v) to 0 step -1
t = c + v(i) + u(i)
v(i) = t mod 10000
c = c \ 10000
next i
To multiply by a number k (integer) then
Code:
c = 0
for i = ubound(v) to 0 step -1
t = c + v(i) * k
v(i) = t mod 10000
c = c \ 10000
next i
This is from a project to calculate pi, that why v(0) is the integer part but you can change it.
And the error is not as simply as you say. If you have to add 1000 number, and each one have an error of 1D-50 the error at most will be 1000 * 1D-50. Now what i you have to add an infinite amount of numbers?