My first experience with GMP big integers… The simple test below can’t be compiled because the get_ui
member function is not found. The function get_ui
is mentioned in the GMP manual.
#include <iostream>
#include <gmpxx.h>
using std::cout;
using std::endl;
int main()
{
mpz_class a(1);
for (auto n = 0U; n < 100; ++n) a *= 10;
cout << a << endl;
auto b = a % 10;
cout << b << endl;
auto c = b.get_ui();
cout << c << endl;
}
The compiler output:
tc0001.cpp:27:14: error: ‘class __gmp_expr<__mpz_struct [1], __gmp_binary_expr<__gmp_expr<__mpz_struct [1], __mpz_struct [1]>, long int, __gmp_binary_modulus> >’ has no member named ‘get_ui’
27 | auto c = b.get_ui();
| ^~~~~~
The system environment:
- OS: Ubuntu 22.04.4 LTS
- Compiler: g++ (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0
- Compiler flags: g++ -g -Wall -std=c++20 tc0001.cpp -o tc0001 -lgmpxx -lgmp
What’s the problem here?