[#absl-uint128] = xref:absl.adoc[absl]::uint128 :relfileprefix: ../ :mrdocs: An unsigned 128‐bit integer type. == Synopsis Declared in `<absl/numeric/int128.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- 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 [cols="1,4"] |=== | Name| Description | xref:absl/uint128/2constructor-00.adoc[`uint128`] [.small]#[constructor]# | Constructors | xref:absl/uint128/operator_assign-0c.adoc[`operator=`] | Assignment operators | xref:absl/uint128/operator_mod_eq.adoc[`operator%=`] | Divides this value by `other` and stores the remainder in place. | xref:absl/uint128/operator_and_eq.adoc[`operator&=`] | Applies a bitwise AND with `other` and stores the result in place. | xref:absl/uint128/operator_star_eq.adoc[`operator*=`] | Multiplies this value by `other` and stores the result in place. | xref:absl/uint128/operator_inc-02.adoc[`operator++`] | Increment operators | xref:absl/uint128/operator_plus_eq.adoc[`operator+=`] | Adds `other` to this value and stores the result in place. | xref:absl/uint128/operator_dec-046.adoc[`operator‐‐`] | Decrement operators | xref:absl/uint128/operator_minus_eq.adoc[`operator‐=`] | Subtracts `other` from this value and stores the result in place. | xref:absl/uint128/operator_slash_eq.adoc[`operator/=`] | Divides this value by `other` and stores the quotient in place. | xref:absl/uint128/operator_lshift_eq.adoc[`operator<<=`] | Shifts this value left by the given number of bits in place. | xref:absl/uint128/operator_rshift_eq.adoc[`operator>>=`] | Shifts this value right by the given number of bits in place. | xref:absl/uint128/operator_xor_eq.adoc[`operatorˆ=`] | Applies a bitwise XOR with `other` and stores the result in place. | xref:absl/uint128/operator_or_eq.adoc[`operator|=`] | Applies a bitwise OR with `other` and stores the result in place. | xref:absl/uint128/2conversion-0e.adoc[`operator __int128`] | Converts this `uint128` to a signed `__int128`. | xref:absl/uint128/2conversion-04c.adoc[`operator bool`] | Converts this `uint128` to a `bool`. | xref:absl/uint128/2conversion-00.adoc[`operator char`] | Converts this `uint128` to a `char`, keeping the low bits. | xref:absl/uint128/2conversion-037.adoc[`operator char16_t`] | Converts this `uint128` to a `char16_t`, keeping the low bits. | xref:absl/uint128/2conversion-0f1.adoc[`operator char32_t`] | Converts this `uint128` to a `char32_t`, keeping the low bits. | xref:absl/uint128/2conversion-0c.adoc[`operator double`] | Converts this `uint128` to a `double`. | xref:absl/uint128/2conversion-022.adoc[`operator float`] | Converts this `uint128` to a `float`. | xref:absl/uint128/2conversion-082.adoc[`operator int`] | Converts this `uint128` to an `int`, keeping the low bits. | xref:absl/uint128/2conversion-05.adoc[`operator long`] | Converts this `uint128` to a `long`, keeping the low bits. | xref:absl/uint128/2conversion-028.adoc[`operator long double`] | Converts this `uint128` to a `long double`. | xref:absl/uint128/2conversion-083.adoc[`operator long long`] | Converts this `uint128` to a `long long`, keeping the low bits. | xref:absl/uint128/2conversion-0fc.adoc[`operator short`] | Converts this `uint128` to a `short`, keeping the low bits. | xref:absl/uint128/2conversion-09b.adoc[`operator signed char`] | Converts this `uint128` to a `signed char`, keeping the low bits. | xref:absl/uint128/2conversion-01f.adoc[`operator unsigned __int128`] | Converts this `uint128` to an `unsigned __int128`. | xref:absl/uint128/2conversion-039.adoc[`operator unsigned char`] | Converts this `uint128` to an `unsigned char`, keeping the low bits. | xref:absl/uint128/2conversion-01a.adoc[`operator unsigned int`] | Converts this `uint128` to an `unsigned int`, keeping the low bits. | xref:absl/uint128/2conversion-099.adoc[`operator unsigned long`] | Converts this `uint128` to an `unsigned long`, keeping the low bits. | xref:absl/uint128/2conversion-041.adoc[`operator unsigned long long`] | Converts this `uint128` to an `unsigned long long`, keeping the low bits. | xref:absl/uint128/2conversion-0f2.adoc[`operator unsigned short`] | Converts this `uint128` to an `unsigned short`, keeping the low bits. | xref:absl/uint128/2conversion-0b.adoc[`operator wchar_t`] | Converts this `uint128` to a `wchar_t`, keeping the low bits. |=== == Friends [cols="1,4"] |=== | Name| Description | `xref:absl/AbslStringify-010.adoc[absl::AbslStringify]` | Appends the decimal representation of this value to a sink, supporting `absl::StrCat()` and related functions. | `xref:absl/AbslHashValue-0d06.adoc[absl::AbslHashValue]` | Combines this value into a hash state, supporting `absl::Hash`. | `xref:absl/Uint128Max.adoc[absl::Uint128Max]` | Returns the highest value for a 128‐bit unsigned integer. | `xref:absl/MakeUint128.adoc[absl::MakeUint128]` | Constructs a `uint128` numeric value from two 64‐bit unsigned integers. | `xref:absl/Uint128High64.adoc[absl::Uint128High64]` | Returns the higher 64‐bit value of a `uint128` value. | `xref:absl/Uint128Low64.adoc[absl::Uint128Low64]` | Returns the lower 64‐bit value of a `uint128` value. |=== == Non-Member Functions [cols="1,4"] |=== | Name| Description | xref:absl/operator_not.adoc[`operator!`] | Returns the logical negation of `val`. | xref:absl/operator_not_eq-02.adoc[`operator!=`] | Determines whether `lhs` and `rhs` are unequal. | xref:absl/operator_mod-0c.adoc[`operator%`] | Returns the remainder of `lhs` divided by `rhs`. | xref:absl/operator_bitand-0b.adoc[`operator&`] | Returns the bitwise AND of `lhs` and `rhs`. | xref:absl/operator_star-05.adoc[`operator*`] | Returns the product of `lhs` and `rhs`. | xref:absl/operator_plus-00.adoc[`operator+`] | Returns the unary plus of `val`, which is `val` unchanged. | xref:absl/operator_plus-07.adoc[`operator+`] | Returns the sum of `lhs` and `rhs`. | xref:absl/operator_minus-05.adoc[`operator‐`] | Returns the difference of `lhs` and `rhs`. | xref:absl/operator_minus-06.adoc[`operator‐`] | Returns the arithmetic negation of `val`. | xref:absl/operator_slash-0a.adoc[`operator/`] | Returns the quotient of `lhs` divided by `rhs`. | xref:absl/operator_lt-0c3.adoc[`operator<`] | Determines whether `lhs` is less than `rhs`. | xref:absl/operator_lshift-024.adoc[`operator<<`] | Shifts `lhs` left by the given number of bits. | xref:absl/operator_le-01.adoc[`operator<=`] | Determines whether `lhs` is less than or equal to `rhs`. | xref:absl/operator_3way-02.adoc[`operator<=>`] | Performs a three‐way comparison of `lhs` and `rhs`. | xref:absl/operator_eq-0db.adoc[`operator==`] | Determines whether `lhs` and `rhs` are equal. | xref:absl/operator_gt-0b.adoc[`operator>`] | Determines whether `lhs` is greater than `rhs`. | xref:absl/operator_ge-09.adoc[`operator>=`] | Determines whether `lhs` is greater than or equal to `rhs`. | xref:absl/operator_rshift-040.adoc[`operator>>`] | Shifts `lhs` right by the given number of bits. | xref:absl/operator_xor-0e.adoc[`operatorˆ`] | Returns the bitwise XOR of `lhs` and `rhs`. | xref:absl/operator_bitor-086.adoc[`operator|`] | Returns the bitwise OR of `lhs` and `rhs`. | xref:absl/operator_bitnot-00.adoc[`operator~`] | Returns the bitwise complement of `val`. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#