Is it possible to define a custom data type? Say, one that holds approximately... 10 million digits?!!
Just curious. Is this possible? Otherwise, how can I work with insanely huge integers?
Is it possible to define a custom data type? Say, one that holds approximately... 10 million digits?!!
Just curious. Is this possible? Otherwise, how can I work with insanely huge integers?
Consider GMP.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
i recommend gmp as well for large integers
Gentoo Linux - 2.6.22.1
GCC version 4.2.0
Just for this post my integer literals are decimal.
If you're trying to generate multiples or powers of low integers like 1,2,3,4,5,etc
you might be able to pull it off by
using an array.
If however,you want something complex like square roots or large primes then I
would suggest GMP. I never figured out how to use any other C libraries though.
I've written my own easy to use and understand, huge-number class.
You can find it on the useful classes link from the page in my signature.
However 10 million decimal digits is pretty extreme. They'd take a little over 30MB each! That would probably blow the stack in my code, even though I've done a fair bit to reduce stack usage.
Determining if a large number is prime is extremely hard to do in a scalable manner, but things like square root aren't much trouble.
Whether or not you need to use such a thing depends on exactly what you are wanting to do. There are a number of algorithms which output a large number of digits but don't involve storing the entire answer at every point through the calculation. Please explain your intent.
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"