A good and basic implementation of BigInt class in C++

Bebeoix picture Bebeoix · May 14, 2012 · Viewed 40.4k times · Source

I'm looking for a good and basic BigInt class in C++, I find a lot of implementation but most of the time, it's complex implementation for crypto library...

By basic, I mean BigInt can deal with BigInt, long long and strings with operator overloading. If I had time, I had done myself but I do not have time to create an entire BigInt class.

Answer

user2001885 picture user2001885 · May 28, 2013

The simplest library I know of is InfInt. It consists of just one header file. Its usage is fairly simple. Here is a sample code:

InfInt myint1 = "15432154865413186646848435184100510168404641560358";
InfInt myint2 = 156341300544608LL;

myint1 *= --myint2 - 3;
std::cout << myint1 << std::endl;