An unsigned 128 bit integer type for C++
Copyright (c) 2013 - 2018 Jason Lee @ calccrypto at gmail.com
Please see LICENSE file for license.
With much help from Auston Sterling
Thanks to Stefan Deigmüller for finding a bug in operator*.
Thanks to François Dessenne for convincing me to do a general rewrite of this class.
Thanks to John Skaller for making symbols visible
when compiling as a shared library. This was originally
done in uint256_t, which I copied into here.
This is simple implementation of an unsigned 128 bit
integer type in C++. It's meant to be used like a standard
uintX_t, except with a larger bit size than those provided
by C/C++.
All that needs to be done in code is #include "uint128.h"
#include <iostream>
#include "uint128.h"
int main() {
uint128_t a = 1;
uint128_t b = 2;
std::cout << (a | b) << std::endl;
return 0;
}A C++ compiler supporting at least C++23 is required.
This library is header-only, so no compilation is required. However, if you want to build and run tests, you need to compile the library. Compilation can be done by using cmake toolchain.
mkdir build && cd buildcmake -DWITH_TESTS=ON ..ninjactest