A signed 128‐bit integer type.

Synopsis

Declared in <absl/numeric/int128.h>

class int128;

Description

The API is meant to mimic an intrinsic integral type as closely as is practical, including exhibiting undefined behavior in analogous cases (e.g. division by zero).

An int128 supports the following:

* Implicit construction from integral types * Explicit conversion to integral types

However, an int128 differs from intrinsic integral types in the following ways:

* It is not implicitly convertible to other integral types. * Requires explicit construction from and conversion to floating point types.

Additionally, if your compiler supports __int128, int128 is interoperable with that type. (Abseil checks for this compatibility through the ABSL_HAVE_INTRINSIC_INT128 macro.)

The design goal for int128 is that it will be compatible with a future int128_t, if that type becomes a part of the standard.

Example:

float y = absl::int128(17); // Error. int128 cannot be implicitly // converted to float.

absl::int128 v; int64_t i = v; // Error int64_t i = static_cast<int64_t>(v); // OK

Member Functions

Name

Description

int128 [constructor]

Constructors

operator=

Assignment operators

operator%=

Divides this value by other and stores the remainder in place.

operator&=

Applies a bitwise AND with other and stores the result in place.

operator*=

Multiplies this value by other and stores the result in place.

operator++

Increment operators

operator+=

Adds other to this value and stores the result in place.

operator‐‐

Decrement operators

operator‐=

Subtracts other from this value and stores the result in place.

operator/=

Divides this value by other and stores the quotient in place.

operator<<=

Shifts this value left by amount bits in place.

operator>>=

Shifts this value right by amount bits in place.

operatorˆ=

Applies a bitwise XOR with other and stores the result in place.

operator|=

Applies a bitwise OR with other and stores the result in place.

operator __int128

Converts this int128 to a signed __int128.

operator bool

Converts this int128 to a bool.

operator char

Converts this int128 to a char, keeping the low bits.

operator char16_t

Converts this int128 to a char16_t, keeping the low bits.

operator char32_t

Converts this int128 to a char32_t, keeping the low bits.

operator double

Converts this int128 to a double.

operator float

Converts this int128 to a float.

operator int

Converts this int128 to an int, keeping the low bits.

operator long

Converts this int128 to a long, keeping the low bits.

operator long double

Converts this int128 to a long double.

operator long long

Converts this int128 to a long long, keeping the low bits.

operator short

Converts this int128 to a short, keeping the low bits.

operator signed char

Converts this int128 to a signed char, keeping the low bits.

operator unsigned __int128

Converts this int128 to an unsigned __int128.

operator unsigned char

Converts this int128 to an unsigned char, keeping the low bits.

operator unsigned int

Converts this int128 to an unsigned int, keeping the low bits.

operator unsigned long

Converts this int128 to an unsigned long, keeping the low bits.

operator unsigned long long

Converts this int128 to an unsigned long long, keeping the low bits.

operator unsigned short

Converts this int128 to an unsigned short, keeping the low bits.

operator wchar_t

Converts this int128 to a wchar_t, keeping the low bits.

Friends

Name

Description

absl::AbslStringify

Appends the decimal representation of this value to a sink, supporting absl::StrCat() and related functions.

absl::AbslHashValue

Combines this value into a hash state, supporting absl::Hash.

absl::Int128Min

Returns the minimum value for a 128‐bit signed integer.

absl::Int128Max

Returns the maximum value for a 128‐bit signed integer.

absl::MakeInt128

Constructs an int128 numeric value from two 64‐bit integers.

absl::Int128High64

Returns the higher 64‐bit value of an int128 value.

absl::Int128Low64

Returns the lower 64‐bit value of an int128 value.

Non-Member Functions

Name

Description

operator!=

Determines whether lhs and rhs are unequal.

operator%

Returns the remainder of lhs divided by rhs.

operator&

Returns the bitwise AND of lhs and rhs.

operator*

Returns the product of lhs and rhs.

operator+

Returns the sum of lhs and rhs.

operator+

Returns the unary plus of val, which is val unchanged.

operator‐

Returns the difference of lhs and rhs.

operator‐

Returns the arithmetic negation of v.

operator/

Returns the quotient of lhs divided by rhs.

operator<<

Shifts lhs left by the given number of bits.

operator>>

Shifts lhs right by the given number of bits.

operatorˆ

Returns the bitwise XOR of lhs and rhs.

operator|

Returns the bitwise OR of lhs and rhs.

Created with MrDocs