# Large numbers calculation

I think this question has more mathematical background than computional, then I'm gonna ask it here.

I was thinking about large numbers calculation. Let's say I have the number $16777735$ stored in memory like this:

$256^0$ $256^1$ $256^2$ $256^3$ $256^4$ $256^5$
--$7$----$2$------$0$----$1$-----$0$-----$0$--

How can I write this number to screen, let's say, in base $10$? Imagine that I CANNOT sum all the parts like $7 + 256\cdot2 + 256^3$, like I couldn't deal with a byte of this size. (I'm only interested in the algorithm, so imagine I have a really large number that can't fit in to a byte, this is just an example)

And also, how to calculate, like, lots of digits of $\pi$, with this same method? I need a way to do these calculations. I'm interested in learning, so I'm asking about the mathematical process of this.

Thank you :)

-
just a note: --7--2--0--1--0--0-- is 16777735 in base 256. –  udiboy1209 Jul 25 '13 at 7:39
There are many good books with algorithm for base conversion, e.g. Knuth's Seminumerical algorithms or Brent/Zimmermann's Modern Computer Arithmetik <maths.anu.edu.au/~brent/pd/mca-cup-0.5.9.pdf>; @udiboy: you mean base 10 –  gammatester Jul 25 '13 at 8:11
Another very good book is Modern Computer Algebra by Joachim von zur Gathen. It goes however well beyond number representations. –  siddhadev Jul 25 '13 at 8:21

One method is to use the fairly standard method of converting to decimal, such as repeated remainders, eg you make up an array, and repeatedly divide the number by 10 (with carries), and carry the last digit over to the array.

For example, you divide 7.2.0.1 by 10, to get 205.153.25 r 5. You put 5 into a(0), and then go back for another digit, getting 97.142.2 remainder 3, the 3 is parked into a(1).

Another method that one could do, is to actually get your computer to work in decimal, like REXX does. There are papers by Mike Colishaw (who wrote REXX), about implementing decimal calculations in computer-arithmetic.

-