An unsigned 128‐bit integer type.
Synopsis
Declared in <absl/numeric/int128.h>
class uint128;
Description
The API is meant to mimic an intrinsic type as closely as is practical, including exhibiting undefined behavior in analogous cases (e.g. division by zero). This type is intended to be a drop‐in replacement once C++ supports an intrinsic uint128_t type; when that occurs, existing well‐behaved uses of uint128 will continue to work using that new type.
Note: code written with this type will continue to compile once uint128_t is introduced, provided the replacement helper functions Uint128(Low|High)64() and MakeUint128() are made.
A uint128 supports the following:
* Implicit construction from integral types * Explicit conversion to integral types
Additionally, if your compiler supports __int128, uint128 is interoperable with that type. (Abseil checks for this compatibility through the ABSL_HAVE_INTRINSIC_INT128 macro.)
However, a uint128 differs from intrinsic integral types in the following ways:
* Errors on implicit conversions that do not preserve value (such as loss of precision when converting to float values). * Requires explicit construction from and conversion to floating point types. * Conversion to integral types requires an explicit static_cast() to mimic use of the ‐Wnarrowing compiler flag. * The alignment requirement of uint128 may differ from that of an intrinsic 128‐bit integer type depending on platform and build configuration.
Example:
float y = absl::Uint128Max(); // Error. uint128 cannot be implicitly // converted to float.
absl::uint128 v; uint64_t i = v; // Error uint64_t i = static_cast<uint64_t>(v); // OK
Member Functions
Name |
Description |
|
Constructors |
Assignment operators |
|
Divides this value by |
|
Applies a bitwise AND with |
|
Multiplies this value by |
|
Increment operators |
|
Adds |
|
Decrement operators |
|
Subtracts |
|
Divides this value by |
|
Shifts this value left by the given number of bits in place. |
|
Shifts this value right by the given number of bits in place. |
|
Applies a bitwise XOR with |
|
Applies a bitwise OR with |
|
Converts this |
|
Converts this |
|
Converts this |
|
Converts this |
|
Converts this |
|
Converts this |
|
Converts this |
|
Converts this |
|
Converts this |
|
Converts this |
|
Converts this |
|
Converts this |
|
Converts this |
|
Converts this |
|
Converts this |
|
Converts this |
|
Converts this |
|
Converts this |
|
Converts this |
|
Converts this |
Friends
Name |
Description |
Appends the decimal representation of this value to a sink, supporting |
|
Combines this value into a hash state, supporting |
|
Returns the highest value for a 128‐bit unsigned integer. |
|
Constructs a |
|
Returns the higher 64‐bit value of a |
|
Returns the lower 64‐bit value of a |
Non-Member Functions
Name |
Description |
Returns the logical negation of |
|
Determines whether |
|
Returns the remainder of |
|
Returns the bitwise AND of |
|
Returns the product of |
|
Returns the unary plus of |
|
Returns the sum of |
|
Returns the difference of |
|
Returns the arithmetic negation of |
|
Returns the quotient of |
|
Determines whether |
|
Shifts |
|
Determines whether |
|
Performs a three‐way comparison of |
|
Determines whether |
|
Determines whether |
|
Determines whether |
|
Shifts |
|
Returns the bitwise XOR of |
|
Returns the bitwise OR of |
|
Returns the bitwise complement of |
Created with MrDocs