Skip to content

calccrypto/uint128_t

Folders and files

NameName
Last commit message
Last commit date

Latest commit

0c916f2 · Jun 24, 2023

History

57 Commits
Jan 17, 2022
Jan 17, 2022
Mar 27, 2017
Feb 16, 2020
Mar 27, 2017
Jan 17, 2022
Sep 20, 2020
Sep 9, 2018
Jun 24, 2023
Sep 9, 2018
Jan 17, 2022
Sep 9, 2018

Repository files navigation

uint128_t

An unsigned 128 bit integer type for C++

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

Please see LICENSE file for license.

uint128_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. This was originally done in uint256_t, which I copied into here.

Usage

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++.

In Code

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

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

int main() {
    uint128_t a = 1;
    uint128_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 in your compile command, e.g. g++ -std=c++11 main.cpp uint128_t.cpp, or other ways, such as linking the uint128_t.o file, or creating a library, and linking the library in.