//absl/numeric library provides only one header file at this time:
int128.h header file defines 128-bit integer types, for use until
intrinsic 128-bit types are part of the C++ standard. Currently, this file
defines only one type:
uint128, an unsigned 128-bit integer; a signed 128-bit
integer is forthcoming.
uint128 type defines an unsigned 128-bit integer. The API is meant to
mimic an intrinsic type as closely as possible, so that any forthcoming
uint128_t can be a drop-in replacement. (
uint128 will be removed once C++
supports such a type.)
NOTE: code written with this type will continue to compile once
is introduced, provided the replacement helper functions
MakeUint128() are made.
uint128 supports the following:
Additionally, if your compiler supports the
__int128 type extension,
is interoperable with that type.
128-bit integer literals are not yet a part of the C++ language. As a result,
to construct a 128-bit unsigned integer with a value greater than or equal to
2^64, you will need to use the
absl::MakeUint128() factory function.
uint64_t a; // Implicit conversion from uint64_t OK uint128 v = a; // Error: Implicit conversion to uint64_t not OK uint64_t b = v; // Explicit conversion to uint64_t OK uint64_t i = static_cast<uint64_t>(v); // Construct a value of 2^64 absl::uint128 big = absl::MakeUint128(1, 0);