faheel / BigInt

Arbitrary-sized integer class for C++
https://faheel.github.io/BigInt
MIT License
390 stars 132 forks source link
arbitrary-size big-int bigint biginteger class cpp cpp11 cpp14 cpp17

BigInt

Arbitrary-sized integer class for C++


Release version GitHub CI CodeFactor Codecov Try it online License

:construction: Work in progress :construction:

Contents

Highlights

Usage

  1. Download the single-include header file to a location under your include path. Then #include it in your code:

    #include "BigInt.hpp"   // the actual path may vary
  2. Create objects of the BigInt class, and do what you got to do!

    BigInt big1 = 1234567890, big2;
    big2 = "9876543210123456789098765432101234567890";
    
    std::cout << big1 * big2 * 123456 << "\n";
    // Output: 1505331490682966620443288524512589666204282352096057600

Features

Operators

Functions

Development

Since this project is built as a header-only library, there are no source files. However, there are unit tests for each header file that the project is split into. These can be compiled and built either through the command line, or using an IDE that has direct support for CMake (such as CLion, Qt Creator) or for which CMake can generate project files (Visual Studio, Eclipse CDT, Code::Blocks and more).

Using the command line

On Linux and macOS, you can compile and run the tests using the command line from the project's root directory.

Using an IDE that supports CMake

  1. Load the project directory in your IDE.
  2. In the build settings for CMake, which can usually be found at Settings > Build > CMake, set the Generation path to build.

Then you can simply select which target (unit test) you want to build/run, and your IDE will do the rest.

In case your IDE does not support CMake directly, you will need to run cmake via the command line with the appropriate flags to generate the project files for your IDE. Give it a try, it's not supposed to be hard!

Contributing

Please read the contributing guidelines for details on how to contribute to the project.

License

This project is licensed under the terms of the MIT license.