BigInt is a numeric type that can represent integers with arbitrary precision. This allows the user to safely store and perform arithmetic on numbers greater than the CPU architecture limit without risk of overflow. At least, this will be the case when the project is fully implemented.
Project Goals
- First and foremost, accuracy.
- Optimize until BigInt is blazing fast.
- Support for x86 and x64 architechtures.
- Port to C++ to make use of operator overloads.
Feature Roadmap
Implement reserve, value, and string parsing constructorPR #1Implement addition operationsPR #4Implement subtraction operationsPR #5- Implement multiplication operations
- Implement division operations
- Implement exponention operations
- Release version 1.0.0!
All releases are header only, meaning all you need to do is download the latest release here, place the header into a visible include path, then include the file in your project. Note: Currently there are no releases
Here's a sample function that can display the Nth fibonacci number. It's important to note that this function is only limited by the amount of memory on your machine. This is the idea of the BigInt library.
void run_BigFibonacci(unsigned n)
{
BigInt* a = val_BigInt(0);
BigInt* b = val_BigInt(1);
printf("Fibonacci Number %d is:\n", n);
for (unsigned i = 1; i < n; ++i)
{
BigInt* c = add(a, b);
free_BigInt(a);
a = b;
b = c;
}
display(b);
free_BigInt(a);
free_BigInt(b);
return;
}
Running this function with n=1000 will print:
0x21d8cb07b572c25732bb116f2c33bab0e83d0c699bad1a727a736a7e42ca93b697ad224d55398373062f18ff62b99c28068131a3fab0c12e3510283c1d60b00930b7e8803c312b4c8e6d5286805fc70b594dc75cc0604b
Currently, BigInt only support hexadecimal for input/output. However, I am open for contributors to pitch in and build support for input/output with arbitrary bases.
This repo utilizes Premake5 to build the necessary project files. Once premake5 is installed just run:
premake5 gmake
This will generate the GNU makefiles for this project. If you need specific project files run 'premake5 --help' for a list of supported actions. See the Premake5 documentaion for further usage instructions.
If the GNU makefiles suffice, then you can generate the File_Reader static library and unit tests by running:
cd gmake/ && make
By default make will build the debug_x64 build. To get a list of configurations run 'make help'. Then to build, for example, release_x64 run:
make config=release_x64
I've included a postbuild command in premake5.lua that will run the unit tests automatically, however if you want to rerun the tests they are located in bin/tests/
This project is licensed under the MIT License - see the LICENSE.md file for details