Int128: Portable and Performant 128-bit integers

Matt Borland

Description

Boost.Int128 is a portable implementation of a signed, and an unsigned 128-bit integer and related functionality (i.e. <bit>, <iostream>, etc). Importantly, on all platforms, the sizeof the types provided in this library are exactly 128-bits.

The library is header-only, has no dependencies, and requires only C++14.

Motivation

128-bit integers are remarkably useful in a number of domains, but portability is often an issue. An example is a 64-bit machine running Linux (say Ubuntu 24.04) has __int128, but the same exact machine running Windows does not have this type.

Use Cases

Anywhere 128-bit integers are needed.

Supported Compilers

Boost.Int128 is tested natively on Ubuntu (x86_64, x86_32, s390x, aarch64, ARM32v7), macOS (x86_64, and Apple Silicon), and Windows (x86_64, x86_32, and ARM64); as well as emulated PPC64LE using QEMU with the following compilers:

  • GCC 5 and later

  • Clang 5 and later

  • Visual Studio 2017 (14.1) and later

  • Intel OneAPI DPC++ 2024.2 and later

Tested on Github Actions and Drone. Coverage can be found on Codecov.