Storing insanely large numbers

I would like to get input from you on how to store insanely large numbers. By insanely large, I’m thinking of numbers that can go up to 100 zeros.

I’ve read about BigInteger it’s not available in .NET 2.0. I’m wondering if I need to build my own struct to support this feature.

Thanks!

It's gotta be asked... why?

–

Also... what? As in, what do you want to be able to do with them?

–

If you just want to "store" the number, just use a string. If you want to be able to use the number to do calculations or something, you are not going to be able to do anything without a very creative/tedious solution. the why and what questions are really bugging me too

–

And if you want to be able to do calculations, then to what level of precision? (I'm thinking of doubles here...)

–

The maximum range for doubles is up to about 300 zeroes.

–

2 Answers

2

you could make your own InsanelyBigInt class, where data stored like int[] data.
as far as Int capacity is 2,147,483,647 , each data element would represent a MegaDigit.
e.g. if data[1]=222333444 and data[1]=555666777, that the real value is 222333444555666777. with unlimited number of data[] items you could store numbers with up to million digits.
but:
1. you will have to define all operations on this class (+, -, *, /, =, ==, !=) and .ToString and .Parse methods, and conversion to/from int type at least (to be able input, output and operate them).
2. and the second thing… really, WHAT FOR??? :slight_smile: