9#if defined __x86_64 && !defined _MSC_VER
14[[nodiscard]]
constexpr uint64_t low64 (
uint128 a) {
return narrow_cast<uint64_t>(a >> 0); }
15[[nodiscard]]
constexpr uint64_t high64(
uint128 a) {
return narrow_cast<uint64_t>(a >> 64); }
77 hi += b.hi + (lo < old_lo);
89 lo = (hi << (64 - n)) | (lo >> n);
101 hi = (hi << n) | (lo >> (64 - n));
131 auto [q, r] = div(b);
137 auto [q, r] = div(b);
146 constexpr uint128(uint64_t low, uint64_t high) : lo(low), hi(high) {}
148 [[nodiscard]]
constexpr std::pair<uint128, uint128> div(
const uint128& ds)
const;
150 [[nodiscard]]
constexpr bool bit(
unsigned n)
const
153 return (lo & (1ULL << n)) != 0;
155 return (hi & (1ULL << (n - 64))) != 0;
159 constexpr void setBit(
unsigned n)
164 hi |= (1ULL << (n - 64));
216 if (
auto cmp =
high64(a) <=>
high64(b); cmp != 0)
return cmp;
261constexpr std::pair<uint128, uint128> uint128::div(
const uint128& ds)
const
Unsigned 128-bit integer type.
constexpr friend uint128 operator*(const uint128 &a, const uint128 &b)
constexpr uint128 & operator*=(const uint128 &b)
constexpr uint128 operator--(int)
constexpr bool operator==(const uint128 &) const =default
constexpr friend uint128 operator&(const uint128 &a, const uint128 &b)
constexpr friend uint128 operator<<(const uint128 &a, unsigned n)
constexpr uint128 & operator<<=(unsigned n)
constexpr uint128 & operator^=(const uint128 &b)
constexpr uint128 & operator++()
constexpr friend uint128 operator%(const uint128 &a, const uint128 &b)
constexpr friend uint128 operator/(const uint128 &a, const uint128 &b)
constexpr uint128 & operator-=(const uint128 &b)
constexpr bool operator!() const
constexpr uint128(uint64_t a)
constexpr uint128 & operator--()
constexpr uint128 & operator/=(const uint128 &b)
constexpr friend uint128 operator-(const uint128 &a, const uint128 &b)
constexpr uint128 & operator&=(const uint128 &b)
constexpr friend uint128 operator>>(const uint128 &a, unsigned n)
constexpr uint128 operator~() const
constexpr friend uint128 operator|(const uint128 &a, const uint128 &b)
constexpr uint128 & operator|=(const uint128 &b)
constexpr uint128 & operator+=(const uint128 &b)
constexpr uint128 operator-() const
constexpr friend uint128 operator+(const uint128 &a, const uint128 &b)
constexpr uint128 & operator%=(const uint128 &b)
constexpr uint128 & operator>>=(unsigned n)
constexpr uint128 operator++(int)
friend constexpr uint64_t low64(const uint128 &a)
constexpr friend auto operator<=>(const uint128 &a, const uint128 &b)
friend constexpr uint64_t high64(const uint128 &a)
constexpr friend uint128 operator^(const uint128 &a, const uint128 &b)
constexpr bool operator&&(const uint128 &a, const uint128 &b)
constexpr bool operator||(const uint128 &a, const uint128 &b)