This is a cross-platform BigInt library written in C with Builtin C++ support. (not just wrappers, but operator overloading etc.)
This officially supports Linux, Windows and MacOS.
- Construct arbitrary large integers (both positive and negative numbers) in C from a string
- C++ Wraps it in a struct, that is move only, it can be copied, but you need to do it explicitly, via
big_int.copy() - C++ constexpr literal, just write
"1141414141"_nwith arbitrary large strings (you may need to increase the constexpr steps for large strings, see the tests cases on how to do that!) - The C++ Struct has overloaded operators for all supported arithmetic instructions (e.g.
+) - The C++ Struct supports implicit conversions from uin64_t and int64_t.
- Supports serialization to string in dec, bin and hex
- Completely tested, by comparing computation results to the
gmportommathlibrary - The C++ library is header only and in the style of stb libraries, see tests on how to use it, it is completely optional and no C++ compiler is needed, if you only use the C library.
- This implementation stores the underlying data memory efficiently as an uint64_t array
- supports C++ hash, it can be used as index in hashmaps and similar data structures
- supports stream output with io modifiers like
std::binand similar
- Addition
- Subtraction
- Negation
- Multiplication
- Division
- Modulo
- Exponentiation
- Shift (right + left)
- Xor
- Or
- And
- Complement (~)
- Comparison