c8

c8 (calculate) is designed as an easy-to-use arbitrary precision (big number) maths library that has no dependencies other than the standard C++ libraries provided with gcc or clang.

The design of c8 emphasizes ease of use, but it is intended to be used in high performance applications. Comprehensible software should not have to be intrinsically slow!

c8 provides supports for three primary classes of numbers:

  • c8::natural - provides natural numbers (between zero and +infinity)
  • c8::integer - provides integers (between -infinity and +infinity)
  • c8::rational - provides rational numbers (all ratios between -infinity and +infinity)

Each class supports functions to construct objects from, and to export object values to, standard C++ value types.

Between the three classes it's possible to represent all the interesting numbers that a computer can directly represent, since floating point numbers are a subset of the set of rational numbers. By using rationals instead of floating point it's also much easier to avoid some types of computational error.

License

The software is released under a BSD 3-Clause license.

Implementation

The code is written in modern C++, and relies of features found in C++14 and later.

Project wiki and documentation

The project wiki and documentation is hosted on GitHub: https://github.com/dave-hudson/c8/wiki

When I built this code I also tracked the development journey on the wiki. This includes all my notes on how I was performance tuning things, down to the machine instruction level in many cases: https://github.com/dave-hudson/c8/wiki/Dev-Notes

Contributing

Please feel free to submit PRs or to reach out to the author directly.

Source code

The source code can be found on GitHub: https://github.com/dave-hudson/c8