- Home /
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!
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...)
Quite, this is why my bringing doubles into the picture was linked to the questions about what they wanted to do with their numbers. I think it also under$$anonymous$$es the "insanely large" idea. If we're talking about being able to use distinct integers with 300+ digits then it's the precision that's insane, not the size.
Answer by Bunny83 · Feb 03, 2015 at 02:46 PM
http://answers.unity3d.com/questions/355810/bigintegerbigrational.html
http://answers.unity3d.com/questions/890835/biginteger-in-unity3d.html
Answer by hav_ngs_ru · Feb 03, 2015 at 02:58 PM
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[i] 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:
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).
and the second thing... really, WHAT FOR??? :)
Your answer