libdpf/thirdparty/uint256_t
Ryan Henry e4e666f459 Initial import of libdpf.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-24 14:08:32 -06:00
..
.github/workflows Initial import of libdpf. 2026-09-24 14:08:32 -06:00
tests Initial import of libdpf. 2026-09-24 14:08:32 -06:00
.gitignore Initial import of libdpf. 2026-09-24 14:08:32 -06:00
.gitmodules Initial import of libdpf. 2026-09-24 14:08:32 -06:00
endianness.h Initial import of libdpf. 2026-09-24 14:08:32 -06:00
LICENSE Initial import of libdpf. 2026-09-24 14:08:32 -06:00
README.md Initial import of libdpf. 2026-09-24 14:08:32 -06:00
uint128_t.hpp Initial import of libdpf. 2026-09-24 14:08:32 -06:00
uint256_t.build Initial import of libdpf. 2026-09-24 14:08:32 -06:00
uint256_t.cpp Initial import of libdpf. 2026-09-24 14:08:32 -06:00
uint256_t.h Initial import of libdpf. 2026-09-24 14:08:32 -06:00
uint256_t.hpp Initial import of libdpf. 2026-09-24 14:08:32 -06:00
uint256_t.include Initial import of libdpf. 2026-09-24 14:08:32 -06:00
uint256_t_config.include Initial import of libdpf. 2026-09-24 14:08:32 -06:00

uint256_t

An unsigned 256 bit integer type for C++

Copyright (c) 2013 - 2018 Jason Lee @ calccrypto at gmail.com

Please see LICENSE file for license.

uint256_t

Acknowledgements

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.

Usage

This is simple implementation of an unsigned 256 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++.

uint256_t requires uint128_t, which is included.

In Code

All that needs to be done in code is #include "uint256_t.h"

#include <iostream>
#include "uint256_t.h"

int main() {
    uint256_t a = 1;
    uint256_t b = 2;
    std::cout << (a | b) << std::endl;
    return 0;
}

Compilation

A C++ compiler supporting at least C++11 is required.

Compilation can be done by directly including uint128_t.cpp and uint256_t.cpp in your compile command, e.g. g++ -std=c++11 main.cpp uint128_t.cpp uint256_t.cpp, or other ways, such as linking the uint128_t.o and uint256_t.o files, or creating a library, and linking the library in.