Hey:
After messing around with Python for some time for large numerical calculations, I realized that Python is just too slow. It's great for smaller numbers, not to mention easy. However, once I start getting into numbers above around five hundred digits in size, it slows down drastically. So, I've looked into C++ for calculations. However, the Integer data type only goes up to around 2 billion (not digits - total value) - not nearly enough.

To combat this problem, I've looked into Bignum libraries, like the GNU MP (GMP) library. However, I just can't seem to understand the documentation that's supplied with GNU MP, as it's mostly geared towards C users, rather than C++ users.

Can someone point me to a nice, well-written tutorial/guide for using GNU MP? I've already googled for one, but the standard manual seems to be about it. If you can't recommend a good set of instructions for GNU MP, can you recommend a better (or, at least, different) bignum/arbitrary-precision library?

Edit:
If there isn't really anything good for C++, is there another language that would be better for large computations?

4
Contributors
8
Replies
9
Views
9 Years
Discussion Span
Last Post by Peter_APIIT

Did you try the online manual available on it's site?

Did you try the online manual available on it's site?

Yes, but it's rather difficult to understand, and not directed towards C++ users...as I already said.

However, I just can't seem to understand the documentation that's supplied with GNU MP, as it's mostly geared towards C users, rather than C++ users.

All right, I think I've got it. However, I can't figure out how to increase the capacity of the mpz class data type.

Here's my code:

``````#include <iostream>
#include <gmp.h>
#include <gmpxx.h>

int main()
{
mpz_class a;

a=1990090990;

std::cout << a << "\n";
return 0;
}``````

It returns:

``error: ambiguous overload for ‘operator=’ in ‘a = 899996901533920162ll’``

How do I increase the capacity?

Sure that you don't have to put quotes around the number?

I don't know GNU Mp is big integer class library. I thought it was just a library with many arithmetic algorithm only.