16 #ifndef FOXXLL_COMMON_UINT_TYPES_HEADER 17 #define FOXXLL_COMMON_UINT_TYPES_HEADER 25 #include <foxxll/config.hpp> 52 template <
typename HighType>
98 "8 * sizeof(low_type) == 32" 104 "sizeof(uint_pair) == bytes" 108 "sizeof(uint_pair) == digits / 8" 110 static_assert(digits / 8 == bytes,
"digits / 8 == bytes");
139 assert((a >> (low_bits + high_bits)) == 0);
145 return static_cast<uint64_t
>(
high) << low_bits | static_cast<uint64_t>(low);
149 operator uint64_t ()
const 157 return static_cast<uint64_t
>(
high) << low_bits | static_cast<uint64_t>(low);
183 uint64_t add =
static_cast<uint64_t
>(
low) + b.low;
184 low = static_cast<low_type>(add &
low_max());
192 return (low == b.low) && (high == b.high);
198 return (low != b.low) || (high != b.high);
204 return (high < b.high) || (high == b.high && low < b.low);
210 return (high < b.high) || (high == b.high && low <= b.low);
216 return (high > b.high) || (high == b.high && low > b.low);
222 return (high > b.high) || (high == b.high && low >= b.low);
228 return os << a.ull();
272 template <
typename HighType>
277 static const bool is_specialized =
true;
292 static const bool is_signed =
false;
295 static const bool is_integer =
true;
298 static const bool is_exact =
true;
301 static const int radix = 2;
315 static const int min_exponent = 0;
318 static const int min_exponent10 = 0;
321 static const int max_exponent = 0;
324 static const int max_exponent10 = 0;
327 static const bool has_infinity =
false;
332 #endif // !FOXXLL_COMMON_UINT_TYPES_HEADER static uint_pair max()
return an uint_pair instance containing the largest value possible
HighType high_type
higher part type, currently either 8-bit or 16-bit
uint_pair & operator--()
prefix decrement operator (directly manipulates the integer parts)
bool operator<(const uint_pair &b) const
less-than comparison operator
static foxxll::uint_pair< HighType > min()
return an uint_pair instance containing the smallest value possible
bool operator<=(const uint_pair &b) const
less-or-equal comparison operator
static uint_pair max()
return an uint_pair instance containing the largest value possible
static low_type low_max()
return highest value storable in lower part, also used as a mask.
Construct an 40-bit or 48-bit unsigned integer stored in five or six bytes.
bool operator>=(const uint_pair &b) const
greater-or-equal comparison operator
static uint_pair min()
return an uint_pair instance containing the smallest value possible
bool operator>(const uint_pair &b) const
greater comparison operator
uint_pair & operator+=(const uint_pair &b)
addition operator (uses 64-bit arithmetic)
static const foxxll::uint_pair< HighType > round_error()
rounding error is zero
high_type high
member containing higher significant integer value
static foxxll::uint_pair< HighType > lowest()
return an uint_pair instance containing the smallest value possible
static const foxxll::uint_pair< HighType > epsilon()
epsilon is zero
uint_pair(const int32_t &a)
implicit conversion from a simple 32-bit signed integer
uint64_t u64() const
return the number as a uint64_t
bool operator!=(const uint_pair &b) const
inequality checking operator
uint_pair(const low_type &l, const high_type &h)
construct unit pair from lower and higher parts.
uint64_t ull() const
return the number as an uint64_t (unsigned long long)
static const size_t low_bits
number of bits in the lower integer part, used a bit shift value.
class foxxll::uint_pair __attribute__((packed))
uint_pair & operator++()
prefix increment operator (directly manipulates the integer parts)
HighType high_type
higher part type, currently either 8-bit or 16-bit
friend std::ostream & operator<<(std::ostream &os, const uint_pair &a)
make a uint_pair outputtable via iostreams, using unsigned long long.
uint32_t low_type
lower part type, always 32-bit
static uint_pair min()
return an uint_pair instance containing the smallest value possible
static const size_t bytes
number of bytes in uint_pair
uint32_t low_type
lower part type, always 32-bit
low_type low
member containing lower significant integer value
static const size_t digits
number of binary digits (bits) in uint_pair
static foxxll::uint_pair< HighType > max()
return an uint_pair instance containing the largest value possible
static high_type high_max()
return highest value storable in higher part, also used as a mask.
static const size_t high_bits
number of bits in the higher integer part, used a bit shift value.
uint_pair()
empty constructor, does not even initialize to zero!
bool operator==(const uint_pair &b) const
equality checking operator
uint_pair()
empty constructor, does not even initialize to zero!