15 #ifndef THRILL_COMMON_UINT_TYPES_HEADER 16 #define THRILL_COMMON_UINT_TYPES_HEADER 50 template <
typename High_>
89 static_assert(8 *
sizeof(
Low) == 32,
"sizeof Low is 32-bit");
90 static_assert(digits / 8 == bytes,
"digit and bytes ratio is wrong");
97 : low_(l), high_(h) { }
106 : low_(a), high_(0) { }
110 : low_(a), high_(0) {
122 assert((a >> (low_bits + high_bits)) == 0);
127 :
UIntPair(static_cast<unsigned long long>(a)) { }
131 :
UIntPair(static_cast<unsigned long long>(a)) { }
140 return ((uint64_t)high_) << low_bits | (uint64_t)low_;
144 operator uint64_t ()
const {
150 return ((uint64_t)high_) << low_bits | (uint64_t)low_;
173 uint64_t add = low_ + uint64_t(b.
low_);
181 uint64_t add = low_ + uint64_t(b.
low_);
189 uint64_t sub = low_ - uint64_t(b.
low_);
197 uint64_t sub = low_ - uint64_t(b.
low_);
205 return (low_ == b.
low_) && (high_ == b.
high_);
210 return (low_ != b.
low_) || (high_ != b.
high_);
240 return os << a.
ull();
255 #if defined(_MSC_VER) 267 static_assert(
sizeof(
uint40) == 5,
"sizeof uint40 is wrong");
268 static_assert(
sizeof(
uint48) == 6,
"sizeof uint48 is wrong");
276 template <
typename HighType>
277 class numeric_limits<
thrill::common::UIntPair<HighType> >
283 static const bool is_specialized =
true;
298 static const bool is_signed =
false;
301 static const bool is_integer =
true;
304 static const bool is_exact =
true;
307 static const int radix = 2;
321 static const int min_exponent = 0;
324 static const int min_exponent10 = 0;
327 static const int max_exponent = 0;
330 static const int max_exponent10 = 0;
333 static const bool has_infinity =
false;
338 #endif // !THRILL_COMMON_UINT_TYPES_HEADER static uint_pair max()
return an uint_pair instance containing the largest value possible
UIntPair & operator=(const UIntPair &)=default
copy assignment operator
UIntPair(const int32_t &a)
const from a simple 32-bit signed integer
uint64_t u64() const
return the number as a uint64_t
UIntPair(const unsigned long long &a)
construct from an 64-bit unsigned integer
static constexpr size_t bytes
number of bytes in UIntPair
static unsigned high_max()
return highest value storable in higher part, also used as a mask.
uint64_t ull() const
return the number as an uint64 (unsigned long long)
UIntPair operator-(const UIntPair &b) const
subtraction operator (uses 64-bit arithmetic)
friend std::ostream & operator<<(std::ostream &os, const UIntPair &a)
make a UIntPair outputtable via iostreams, using unsigned long long.
static UIntPair min()
return an UIntPair instance containing the smallest value possible
UIntPair & operator-=(const UIntPair &b)
subtraction operator (uses 64-bit arithmetic)
UIntPair(const uint32_t &a)
const from a simple 32-bit unsigned integer
static constexpr size_t low_bits
number of bits in the lower integer part, used a bit shift value.
High_ High
higher part type, currently either 8-bit or 16-bit
UIntPair(const int64_t &a)
construct from an 64-bit signed integer
UIntPair()=default
empty constructor, does not even initialize to zero!
uint32_t Low
lower part type, always 32-bit
static UIntPair lowest()
return an UIntPair instance containing the smallest value possible
static UIntPair min()
return an UIntPair instance containing the smallest value possible
UIntPair & operator++()
prefix increment operator (directly manipulates the integer parts)
bool operator>(const UIntPair &b) const
greater comparison operator
class thrill::common::UIntPair TLX_ATTRIBUTE_PACKED
UIntPair(const unsigned long &a)
construct from an 64-bit signed integer
UIntPair operator+(const UIntPair &b) const
addition operator (uses 64-bit arithmetic)
bool operator>=(const UIntPair &b) const
greater-or-equal comparison operator
static UIntPair max()
return an UIntPair instance containing the largest value possible
static constexpr size_t high_bits
number of bits in the higher integer part, used a bit shift value.
bool operator<=(const UIntPair &b) const
less-or-equal comparison operator
bool operator<(const UIntPair &b) const
less-than comparison operator
static constexpr size_t digits
number of binary digits (bits) in UIntPair
High high_
member containing higher significant integer value
static const UIntPair round_error()
rounding error is zero
UIntPair & operator+=(const UIntPair &b)
addition operator (uses 64-bit arithmetic)
static uint_pair min()
return an uint_pair instance containing the smallest value possible
bool operator!=(const UIntPair &b) const
inequality checking operator
static unsigned low_max()
return highest value storable in lower part, also used as a mask.
Low low_
member containing lower significant integer value
UIntPair(const Low &l, const High &h)
construct unit pair from lower and higher parts.
bool operator==(const UIntPair &b) const
equality checking operator
static const UIntPair epsilon()
epsilon is zero
Construct an 40-bit or 48-bit unsigned integer stored in five or six bytes.
UIntPair & operator--()
prefix decrement operator (directly manipulates the integer parts)
static UIntPair max()
return an UIntPair instance containing the largest value possible