Coding for gigantic numbers

ninguen

New member
Joined
Jan 1, 2012
Messages
41
Any programmers here know how to work with numbers which are larger than the default data types can handle?

ex:

a = 98498394893849839839489384.430983093803848830480938093809380389489309898430849800983;
b = 98498394893849839839489384.430983093803848830480938093809380389489309898430849800983;

c = a*b;

I've always been curious about this.
 
Get in touch with these poor souls:
http://www.numberworld.org/misc_runs/pi-5t/details.html

Assuming 10 digits per inch:
5,000,000,000,000 / (5280*12*10) = ~7,891,414 MILES long :rolleyes:

Was just talking to a friend of mine about it today, and he came up with an interesting suggestion of creating a function that takes long strings or single-digit integer arrays. Then, performing the math the same way you would do it with a pencil and paper.

For example, a division function would perform long division on the strings, one digit at a time.

I can see how this would work on additions, subtractions, and multiplications. Might be harder for square roots and things like that. Not to mention the CPU cycles that must eat up.

That PI calculator idea is really good. I'm sure I can find some open source pi programs that have dealt with this issue in a more elegant way than I just mentioned.
 
You should be able to encode it modulo a dozen or so mutually primes. You'll just have to learn to do arithmetic a little differently.
 
Top