25 #ifndef ABSL_NUMERIC_INT128_H_ 26 #define ABSL_NUMERIC_INT128_H_ 45 #define ABSL_INTERNAL_WCHAR_T __wchar_t 48 #pragma intrinsic(_umul128) 49 #endif // defined(_M_X64) 50 #else // defined(_MSC_VER) 51 #define ABSL_INTERNAL_WCHAR_T wchar_t 52 #endif // defined(_MSC_VER) 101 #if defined(ABSL_HAVE_INTRINSIC_INT128) 102 alignas(
unsigned __int128)
110 constexpr
uint128(
unsigned int v);
112 constexpr
uint128(
unsigned long v);
113 constexpr
uint128(
long long v);
114 constexpr
uint128(
unsigned long long v);
115 #ifdef ABSL_HAVE_INTRINSIC_INT128 117 constexpr
uint128(
unsigned __int128 v);
118 #endif // ABSL_HAVE_INTRINSIC_INT128 121 explicit uint128(
long double v);
124 uint128& operator=(
int v);
125 uint128& operator=(
unsigned int v);
126 uint128& operator=(
long v);
127 uint128& operator=(
unsigned long v);
128 uint128& operator=(
long long v);
129 uint128& operator=(
unsigned long long v);
130 #ifdef ABSL_HAVE_INTRINSIC_INT128 131 uint128& operator=(__int128 v);
132 uint128& operator=(
unsigned __int128 v);
133 #endif // ABSL_HAVE_INTRINSIC_INT128 136 constexpr
explicit operator bool()
const;
137 constexpr
explicit operator char()
const;
138 constexpr
explicit operator signed char()
const;
139 constexpr
explicit operator unsigned char()
const;
140 constexpr
explicit operator char16_t()
const;
141 constexpr
explicit operator char32_t()
const;
143 constexpr
explicit operator short()
const;
145 constexpr
explicit operator unsigned short()
const;
146 constexpr
explicit operator int()
const;
147 constexpr
explicit operator unsigned int()
const;
148 constexpr
explicit operator long()
const;
150 constexpr
explicit operator unsigned long()
const;
152 constexpr
explicit operator long long()
const;
154 constexpr
explicit operator unsigned long long()
const;
155 #ifdef ABSL_HAVE_INTRINSIC_INT128 156 constexpr
explicit operator __int128()
const;
157 constexpr
explicit operator unsigned __int128()
const;
158 #endif // ABSL_HAVE_INTRINSIC_INT128 159 explicit operator float()
const;
160 explicit operator double()
const;
161 explicit operator long double()
const;
166 uint128& operator+=(uint128 other);
167 uint128& operator-=(uint128 other);
168 uint128& operator*=(uint128 other);
170 uint128& operator/=(uint128 other);
171 uint128& operator%=(uint128 other);
172 uint128 operator++(
int);
173 uint128 operator--(
int);
174 uint128& operator<<=(
int);
175 uint128& operator>>=(
int);
179 uint128& operator++();
180 uint128& operator--();
201 friend constexpr uint128
MakeUint128(uint64_t high, uint64_t low);
209 template <
typename H>
215 constexpr
uint128(uint64_t high, uint64_t low);
221 #if defined(ABSL_IS_LITTLE_ENDIAN) 224 #elif defined(ABSL_IS_BIG_ENDIAN) 228 #error "Unsupported byte order: must be little-endian or big-endian." 243 return uint128((std::numeric_limits<uint64_t>::max)(),
244 (std::numeric_limits<uint64_t>::max)());
254 static constexpr
bool is_specialized =
true;
255 static constexpr
bool is_signed =
false;
256 static constexpr
bool is_integer =
true;
257 static constexpr
bool is_exact =
true;
258 static constexpr
bool has_infinity =
false;
259 static constexpr
bool has_quiet_NaN =
false;
260 static constexpr
bool has_signaling_NaN =
false;
261 static constexpr float_denorm_style has_denorm = denorm_absent;
262 static constexpr
bool has_denorm_loss =
false;
263 static constexpr float_round_style round_style = round_toward_zero;
264 static constexpr
bool is_iec559 =
false;
265 static constexpr
bool is_bounded =
true;
266 static constexpr
bool is_modulo =
true;
267 static constexpr
int digits = 128;
268 static constexpr
int digits10 = 38;
269 static constexpr
int max_digits10 = 0;
271 static constexpr
int min_exponent = 0;
272 static constexpr
int min_exponent10 = 0;
273 static constexpr
int max_exponent = 0;
274 static constexpr
int max_exponent10 = 0;
275 #ifdef ABSL_HAVE_INTRINSIC_INT128 276 static constexpr
bool traps = numeric_limits<unsigned __int128>::traps;
277 #else // ABSL_HAVE_INTRINSIC_INT128 278 static constexpr
bool traps = numeric_limits<uint64_t>::traps;
279 #endif // ABSL_HAVE_INTRINSIC_INT128 280 static constexpr
bool tinyness_before =
false;
332 #ifdef ABSL_HAVE_INTRINSIC_INT128 340 #endif // ABSL_HAVE_INTRINSIC_INT128 353 *
this = *
this << amount;
358 *
this = *
this >> amount;
363 *
this = *
this + other;
368 *
this = *
this - other;
373 *
this = *
this * other;
378 *
this = *
this / other;
383 *
this = *
this % other;
393 #if defined(ABSL_IS_LITTLE_ENDIAN) 396 : lo_{low}, hi_{high} {}
399 : lo_{
static_cast<uint64_t
>(
v)},
400 hi_{v < 0 ? (std::numeric_limits<uint64_t>::max)() : 0} {}
402 : lo_{
static_cast<uint64_t
>(
v)},
403 hi_{v < 0 ? (std::numeric_limits<uint64_t>::max)() : 0} {}
405 : lo_{
static_cast<uint64_t
>(
v)},
406 hi_{v < 0 ? (std::numeric_limits<uint64_t>::max)() : 0} {}
414 #ifdef ABSL_HAVE_INTRINSIC_INT128 416 : lo_{
static_cast<uint64_t
>(v & ~uint64_t{0})},
417 hi_{
static_cast<uint64_t
>(
static_cast<unsigned __int128
>(
v) >> 64)} {}
419 : lo_{
static_cast<uint64_t
>(v & ~uint64_t{0})},
420 hi_{
static_cast<uint64_t
>(v >> 64)} {}
421 #endif // ABSL_HAVE_INTRINSIC_INT128 423 #elif defined(ABSL_IS_BIG_ENDIAN) 426 : hi_{high}, lo_{low} {}
429 : hi_{v < 0 ? (std::numeric_limits<uint64_t>::max)() : 0},
430 lo_{
static_cast<uint64_t
>(
v)} {}
432 : hi_{v < 0 ? (std::numeric_limits<uint64_t>::max)() : 0},
433 lo_{
static_cast<uint64_t
>(
v)} {}
435 : hi_{v < 0 ? (std::numeric_limits<uint64_t>::max)() : 0},
436 lo_{
static_cast<uint64_t
>(
v)} {}
444 #ifdef ABSL_HAVE_INTRINSIC_INT128 446 : hi_{
static_cast<uint64_t
>(
static_cast<unsigned __int128
>(
v) >> 64)},
447 lo_{
static_cast<uint64_t
>(v & ~uint64_t{0})} {}
449 : hi_{
static_cast<uint64_t
>(v >> 64)},
450 lo_{
static_cast<uint64_t
>(v & ~uint64_t{0})} {}
451 #endif // ABSL_HAVE_INTRINSIC_INT128 454 #error "Unsupported byte order: must be little-endian or big-endian." 459 constexpr uint128::operator
bool()
const {
return lo_ || hi_; }
461 constexpr uint128::operator char()
const {
return static_cast<char>(lo_); }
463 constexpr uint128::operator
signed char()
const {
464 return static_cast<signed char>(lo_);
467 constexpr uint128::operator
unsigned char()
const {
468 return static_cast<unsigned char>(lo_);
471 constexpr uint128::operator char16_t()
const {
472 return static_cast<char16_t
>(lo_);
475 constexpr uint128::operator char32_t()
const {
476 return static_cast<char32_t
>(lo_);
484 constexpr uint128::operator short()
const {
return static_cast<short>(lo_); }
486 constexpr uint128::operator
unsigned short()
const {
487 return static_cast<unsigned short>(lo_);
490 constexpr uint128::operator int()
const {
return static_cast<int>(lo_); }
492 constexpr uint128::operator
unsigned int()
const {
493 return static_cast<unsigned int>(lo_);
497 constexpr uint128::operator long()
const {
return static_cast<long>(lo_); }
499 constexpr uint128::operator
unsigned long()
const {
500 return static_cast<unsigned long>(lo_);
503 constexpr uint128::operator
long long()
const {
504 return static_cast<long long>(lo_);
507 constexpr uint128::operator
unsigned long long()
const {
508 return static_cast<unsigned long long>(lo_);
511 #ifdef ABSL_HAVE_INTRINSIC_INT128 512 constexpr uint128::operator __int128()
const {
513 return (static_cast<__int128>(hi_) << 64) + lo_;
516 constexpr uint128::operator
unsigned __int128()
const {
517 return (static_cast<unsigned __int128>(hi_) << 64) + lo_;
519 #endif // ABSL_HAVE_INTRINSIC_INT128 523 inline uint128::operator float()
const {
524 return static_cast<float>(lo_) + std::ldexp(static_cast<float>(hi_), 64);
527 inline uint128::operator double()
const {
528 return static_cast<double>(lo_) + std::ldexp(static_cast<double>(hi_), 64);
531 inline uint128::operator
long double()
const {
532 return static_cast<long double>(lo_) +
533 std::ldexp(static_cast<long double>(hi_), 64);
544 return !(lhs == rhs);
672 #if defined(ABSL_HAVE_INTRINSIC_INT128) 675 return static_cast<unsigned __int128
>(lhs) *
676 static_cast<unsigned __int128>(rhs);
677 #elif defined(_MSC_VER) && defined(_M_X64) 683 #else // ABSL_HAVE_INTRINSIC128 692 result +=
uint128(a32 * b00) << 32;
693 result +=
uint128(a00 * b32) << 32;
695 #endif // ABSL_HAVE_INTRINSIC128 722 #if defined(ABSL_HAVE_INTRINSIC_INT128) 723 #include "absl/numeric/int128_have_intrinsic.inc" 724 #else // ABSL_HAVE_INTRINSIC_INT128 725 #include "absl/numeric/int128_no_intrinsic.inc" 726 #endif // ABSL_HAVE_INTRINSIC_INT128 730 #undef ABSL_INTERNAL_WCHAR_T 732 #endif // ABSL_NUMERIC_INT128_H_
constexpr uint128 Uint128Max()
uint128 & operator/=(uint128 other)
chars_format & operator|=(chars_format &lhs, chars_format rhs)
constexpr uint64_t Uint128High64(uint128 v)
bool operator<(const absl::InlinedVector< T, N, A > &a, const absl::InlinedVector< T, N, A > &b)
uint128 operator-(uint128 lhs, uint128 rhs)
uint128 & operator+=(uint128 other)
static constexpr absl::uint128 lowest()
std::ostream & operator<<(std::ostream &os, absl::LogSeverity s)
uint128 operator%(uint128 lhs, uint128 rhs)
static constexpr absl::uint128 signaling_NaN()
constexpr uint64_t Uint128Low64(uint128 v)
uint128 operator^(uint128 lhs, uint128 rhs)
friend H AbslHashValue(H h, uint128 v)
std::pair< uint64_t, uint64_t > uint128
uint128 operator*(uint128 lhs, uint128 rhs)
static constexpr absl::uint128 infinity()
uint128 operator|(uint128 lhs, uint128 rhs)
bool operator>(const absl::InlinedVector< T, N, A > &a, const absl::InlinedVector< T, N, A > &b)
uint128 & operator<<=(int)
uint128 & operator*=(uint128 other)
bool operator==(const absl::InlinedVector< T, N, A > &a, const absl::InlinedVector< T, N, A > &b)
bool operator>=(const absl::InlinedVector< T, N, A > &a, const absl::InlinedVector< T, N, A > &b)
uint128 operator+(uint128 lhs, uint128 rhs)
static constexpr absl::uint128 epsilon()
bool operator!=(const absl::InlinedVector< T, N, A > &a, const absl::InlinedVector< T, N, A > &b)
chars_format & operator^=(chars_format &lhs, chars_format rhs)
uint128 & operator|=(uint128 other)
static constexpr absl::uint128 denorm_min()
#define ABSL_INTERNAL_WCHAR_T
const uint128 kuint128max
uint128 & operator>>=(int)
static constexpr absl::uint128 round_error()
static constexpr absl::uint128 quiet_NaN()
constexpr uint128 MakeUint128(uint64_t high, uint64_t low)
uint128 operator&(uint128 lhs, uint128 rhs)
uint128 & operator%=(uint128 other)
uint128 operator~(uint128 val)
uint128 operator/(uint128 lhs, uint128 rhs)
chars_format & operator&=(chars_format &lhs, chars_format rhs)
uint128 & operator=(int v)
constexpr absl::remove_reference_t< T > && move(T &&t) noexcept
uint128 operator>>(uint128 lhs, int amount)
uint128 & operator&=(uint128 other)
bool operator!(uint128 val)
bool operator<=(const absl::InlinedVector< T, N, A > &a, const absl::InlinedVector< T, N, A > &b)
uint128 & operator-=(uint128 other)
uint128 & operator^=(uint128 other)