Main objective of creating this library is to explore and understand how does arbitrary precision arithmetic works. Don't use this soulution for any production need, only for educational purposes. If you have any question, willing to collaborate or just to discus some parts of the project, feel free to reach out to me. bohdan.kornatskyi@gmail.com
git clone https://github.com/kornatskyi/bignum.git
cd bignum
# Generate build system to the build folder (will be created automatically)
cmake -S . -B build
cd ./build
# Run from `build` folder. Builds the project
make
# Run tests
./bignum_test
# Run main file from `src/`
./bignum
For using as a library
Clone the bignum
project to your project. Include header file BigInt.hpp
from include/
directory into your file why you going to use the BigInt. Add source files from src/
folder to your building tool.
- BigInt - signed integer data type
Dynamic array of characters
std::vector<char> _digits;
Boolean value for storing a sign, initially positive
bool _sign = ture;
- School book addition algorithm. O(n) time complexity
- School book substruction algorithm. O(n) time complexity
- School book multiplication algorithm. O(n^2) time complexity
- Karatsuba's algorithm. O(n^lg3) time complexity
- School book division algorithm. O(n^2) time complexity
- Repeated multiplication and reduction. O(n^2) time complexity
Unit testing is pretty straight forward and self explanatory.
The are to part to benchmarking, test data generation and measuring function efficiency
DataGenerator.hpp
header file contains generateNumberSets()
function which has self explanatory comments and will produce output to the file, by default it's data.txt
file in the same folder where program was started.
After data was generated you need copy-paste int from data.txt
to DataSet.hpp
file in the appropriate field.
Then this data will be fetched by functions in PerformanceTest.hpp
file. The functions fill put output into bignum/performance_test_results/
folder by default.