[ back to toc ]

reading in numbers

Date: 2002/04/10 10:24

Q:
Hi.
I'm having a bit of trouble with this problem. What I'm trying to do is
read in a number, which is passed to the function, into a list. The
problem is, the number is larger than the longest type in C and I need to
read it in back to front.
I also need to keep it as a number, not turn it into a string, so that I
can divide it up and make it useful.
I don't know how the long the number will be. What I thought I could do
would be to read the number into a linked list and then read it back into
another list, 3 nodes at a time
so if the number given was
123456789
I would read it in, one at a time:
1 -> 2 -> 3 -> 4 ->5 ->6 -> 7-> 8-> 9
then:
123 -> 456 -> 789
but this strikes me as particularaly inefficient.
And complicated.
Is there a better way?
Thanks so much for your time.

A:
You can use the Arbitrary Precision Mathematics GNU package to download
from

http://packages.debian.org/stable/math/apcalc.html

This is already an application but you can use extracted code from it.

Regards,
Peter

[ back to toc ]