Arbitrary-precision integer library in C++
For build this library you need:
-
C++ compiler with C++11 or C++03 support;
-
C++ standard headers;
-
Compiler -m32 flag support to create 32-bit version;
-
ar;
-
MinGW C++ compiler i686-w64-mingw32-g++ to build for Windows;
-
zip to create release archive.
For building library run
make
This command will create Release folder with library and headers.
There are some extra flags and arguments:
notest - build library only (without tests)
OS=win - build for Windows
NO_DEBUG=true - disable exceptions log
PLATFORM=x86 - build 32-bit version
STD=c++03 - Use C++03 standard
clean - clean current build
allclean - clean current build and release folder
For example to build library for Windows with tests and without exceptions' logging:
make OS=win NO_DEBUG=true
You can also build all possible libraries for current OS and Windows by
bash build_all.sh
This library provides BigInteger class with simple interface - BigInteger can be used as standard integer types:
#include <iostream>
#include <biginteger.h>
int main() {
BigInteger a(1000), b("340282366920938463463374607431768211456");
BigInteger c = fact(a);
std::cout << a + b << std::endl;
std::cout << c - b << std::endl;
std::cout << a * b << std::endl;
std::cout << b / a << std::endl;
std::cout << b % a << std::endl;
return 0;
}
For more information see tests.cpp file.
You should link BigInteger library to your project to make it work. Please read docs for your IDE or compiler.
To compile the tests, you need to execute
make tests
It will produce tests.exe or tests.out file. Run this file. If there is no error there should be the text:
Tests ended successfully
Xlife - a popular freeware program for the simulation of cellular automata.
You are welcome to open new issue if you have any questions or bugs. Please also mention the version of the library you are using and the version of your compiler and operating system.
If your project uses BigInteger library please let me know and leave a link to this repo in your project.
The library is licensed under the GNU GPL 3. For more information see the LICENSE file.