LargeInt is a C++ header library designed to create unsigned integers of almost any size. With the templated class
design, LargeInt supports the following bit sizes
To deal with possible so large numbers algorithmic wise, the class has a recursive structure, where each LargeInt holds
an upper and lower part, each with half the size. This recursion stops at
The main reason for starting this project, was the Karatsuba algorithm which I learned about in university. This algorithm supports multiplication for any size number by recursively splitting the workload more efficient then the standard school method would do.
Implementation of the division operator was the most tedious part of this project. Finding and implementing a division operation that is compatible with this design was more challenging than expected. In the end, the Burnikel Ziegler division algorithm saved the day.
Download the headers and include the inlcude/large_int/ folder in you project with -I argument.
Once large_int.hpp is included, you can use the LargeInt<N> class. It supports all standard arithmetic, comparison
and unary operators excluding the unary + and - operator. Read the documentation for more info about each operator
if needed.
Note: All operators but the multiplication return a LargeInt with the same size
#include "large_int.hpp"
#include <iostream>
int main() {
LargeInt<128> num1("1234567890123456789");
LargeInt<128> num2(1);
auto res = num1 + num2;
std::cout << res;
}