Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
It is not supported in any data types that are predefined in VB. The only way you could really do this is to store the numbers in string variables (variants may make it a bit easier) and write the math functions to preform the desired tasks on your strings. This can be tricky depending upon your application.
borelli34

Using string functions addition is
relatively easy. When I first read the
posting I thought of multiplication. Since
the subject is multiplication.
There is(was) a BASIC program that does
arbitrary precision multiplication of
large multidigit numbers.An extension of the method would use
arrays to store the partial products of
the multiplication. Then sum them.

Here is a solution in BASIC.
tested to greater than 200 digitsrem long digit addition
rem PowerBasic 3.1 for DOS (should run in QBASIC)x$ = "12345567778888444444444444444444444444"
y$ = "44444444444444444444444444999999004444"rem find longer string and
rem pad shorter with leading "0"
a% = len(x$)
b% = len(y$)
c% = a%
if b% > a% then
c% = b%
x$ = repeat$((b%-a%), "0") + x$
else
y$ = repeat$((a%-b%), "0") + y$
end ifrem display inputs
print x$
print y$
rem work variables
z$ = ""
w% = 0
w$ = ""rem working from end
for p% = c% to 1 step -1
x% = val(mid$(x$,p%,1))
y% = val(mid$(y$,p%,1))
s% = x% + y% + w%
s$ = str$(s%)
z$ = right$(s$,1) + z$rem carry
if (len(s$) > 2) then
w$ = mid$(s$,2,1)
w% = val(w$)
else
w% = 0
end if
next p%rem last carry
if (w% > 0) then
z$ = w$ + z$
end ifprint z$
rem variables
rem x$ = first number string
rem y$ = second number string
rem z$ = output number string
rem a% = length of first number string
rem b% = length of second number string
rem c% = length of longest number string
rem w% = carry digit number
rem w$ = carry digit string
rem p% = position in number string

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |