Is there a library out there that lets you store numbers that are too big for a long long? This is all theoretical--I don't actually have a use for it, I'm just wondering if it's out there.
Is there a library out there that lets you store numbers that are too big for a long long? This is all theoretical--I don't actually have a use for it, I'm just wondering if it's out there.
Yes. For example: GMP. Of course, if you are just storing the numbers, then storing them as strings could suffice.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Some of us even write our own classes for dealing with large numbers.
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"
I tried to compile GMP on cygwin, but I'm getting the following errors:
I checked, and the file libgmp.la does exist at that path. I used/usr/bin/sed: can't read programming/gmp-5.0.5/libgmp.la: No such file or directory
libtool: link: `programming/gmp-5.0.5/libgmp.la' is not a valid libtool archive
Makefile:752: recipe for target `libgmpxx.la' failed
make[2]: *** [libgmpxx.la] Error 1
make[2]: Leaving directory `/cygdrive/c/users/user/desktop/c++ programming/gmp-5.0.5'
Makefile:924: recipe for target `all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/cygdrive/c/users/user/c++ programming/gmp-5.0.5'
Makefile:659: recipe for target `all' failed
make: *** [all] Error 2
./configure --enable-cxx
make
to compile.
In my experience, compiling GMP on Windows is a real pain. I tried doing it using MSYS a while ago and ended up abandoning the idea.
A quick google search turned up this:
apfloat for C++
Seems worth a try, there are other bignum libraries out there aswell, the above is for real numbers, if you want specifically for integers i believe there is one called bigint-cpp, which is object oriented as well.
How I need a drink, alcoholic in nature, after the heavy lectures involving quantum mechanics.
Have you tried placing the library source on a path that does not contain spaces? I have heard that such embedded spaces may cause problems for MinGW, and maybe the same applies for Cygwin.Originally Posted by LyTning94
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
It sounds like you do have a use for it after all, otherwise you probably wouldn't bother trying to get it to work
I do like to encourage others to learn how to get other libraries out there for this working, as it alone can be useful for learning more about how to integrate with these sorts of things. However, I don't ever use the build environment you are using and cant really help in that area.
Did I mention that I maintain my own which is hosted on my website (link below)? It's just one header file. That's it, nothing else, just one file, and one I can certainly help with. If you just want something up and running quickly, to play around with, then by all means give it a go. I don't get anything out of it other than motivation to continue improving it.
If you'd rather go with one of those large packages that do everything but might be harder to use, the following link has several listed:
Arbitrary-precision arithmetic - Wikipedia, the free encyclopedia
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"
I tried this, and it appears to compile fine. I ran 'make check' and all the tests were successful. I then ran 'make install', which as far as I can tell should have installed the .lib file to cygwin/usr/local/lib. I looked there, and the only files there are libgmp.a, libgmp.la, libgmpxx.a, and libgmpxx.la. What are the .a and .la files, and where is the .lib?
@iMalc
Because at the moment I don't have an actual use for it, and am just exploring the possibilities, I'd rather go with a library that has more features, even if it is a pain to set up.
Last edited by LyTning94; 06-01-2012 at 11:44 AM.
These are your library archives, i.e., there is no .lib file. You can link to libgmp.a by passing -lgmp to gcc.Originally Posted by LyTning94
EDIT:
Oh wait, C++. I have forgotten exactly what, but you probably should pass -lgmpxx to g++ then, possibly in addition to -lgmp, especially if you want to use the C++ class wrapper.
Last edited by laserlight; 06-01-2012 at 12:08 PM.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Refer to the docs on Notes for Particular Systems. Basically, you would need to build using MinGW instead to get a DLL from which you can create the .lib file.Originally Posted by LyTning94
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
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"
I thought I'd just download MathX, one of the newer ones mentioned on the wikipedia article I linked to, that I hadn't seen before.
Turns out that its quite similar, but rather primitive feature-wise compared to mine, and uses far slower methods of multiplication and division. (Mine has been around 6 years longer)
It's does some weird thing that I considered a while ago where an N-bit integer is composed of two N/2 bit integers, using the same class in most cases. I decided that idea was crazy, and now that I've seen it done, I don't think it was any less crazy than I imagined.
I can't believe it does unary minus by a multiplication by -1, invoking the slow multiplication algorithm. What on earth was this guy thinking!
The code has way better commenting than mine, and it does look about as easy to use, but with its feature set so tiny, I imagine it wont suit your needs.
Actually, I'm just writing a review of it on sourceforge now...
Last edited by iMalc; 06-01-2012 at 03:47 PM.
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"
While looking for ways to compile GMP in VC++, I stumbled across MPIR, which is a Windows-based version of GMP. I compiled that in VC++ and everything worked great. I haven't tried it out yet, but the .lib file is there.