9 #ifndef CPPCOMMON_UINT256_H
10 #define CPPCOMMON_UINT256_H
34 explicit uint256_t(
const T& value) noexcept;
35 template <
typename TUpper,
typename TLower>
37 template <
typename TUpperUpper,
typename TUpperLower,
typename TLowerUpper,
typename TLowerLower>
38 uint256_t(
const TUpperUpper& upper_upper,
const TUpperLower& upper_lower,
const TLowerUpper& lower_upper,
const TLowerLower& lower_lower) noexcept;
44 uint256_t& operator=(const T& value) noexcept;
49 uint256_t operator+() const noexcept {
return *
this; }
101 template <
typename T>
107 template <
typename T>
109 template <
typename T>
115 template <
typename T>
117 template <
typename T>
123 template <
typename T>
125 template <
typename T>
138 template <
typename T>
140 template <
typename T>
142 template <
typename T>
149 template <
typename T>
151 template <
typename T>
153 template <
typename T>
156 template <
typename T>
158 template <
typename T>
164 template <
typename T>
166 template <
typename T>
172 template <
typename T>
174 template <
typename T>
181 template <
typename T>
183 template <
typename T>
189 template <
typename T>
191 template <
typename T>
197 template <
typename T>
199 template <
typename T>
205 template <
typename T>
207 template <
typename T>
213 template <
typename T>
215 template <
typename T>
221 template <
typename T>
223 template <
typename T>
230 bool operator!() const noexcept {
return !(bool)(_upper | _lower); }
232 template <
typename T>
234 template <
typename T>
240 template <
typename T>
242 template <
typename T>
252 template <
typename T>
254 template <
typename T>
260 template <
typename T>
262 template <
typename T>
265 template <
typename T>
279 template <
typename T>
294 operator bool() const noexcept {
return (
bool)(_upper | _lower); }
295 operator uint8_t() const noexcept {
return (uint8_t)_lower; }
296 operator uint16_t() const noexcept {
return (uint16_t)_lower; }
297 operator uint32_t() const noexcept {
return (uint32_t)_lower; }
298 operator uint64_t() const noexcept {
return (uint64_t)_lower; }
307 size_t bits() const noexcept;
315 std::
string string(
size_t base = 10,
size_t length = 0) const;
333 friend std::istream& operator>>(std::istream& is,
uint256_t& value)
334 { is >> value._upper >> value._lower;
return is; }
337 { is >> value._upper >> value._lower;
return is; }
Unsigned 128-bit integer type.
Unsigned 256-bit integer type.
friend uint256_t operator<<(uint64_t value1, const uint256_t &value2) noexcept
friend uint256_t operator^(const uint128_t &value1, const uint256_t &value2) noexcept
friend bool operator!=(const uint256_t &value1, const uint128_t &value2) noexcept
friend uint256_t operator*(const uint256_t &value1, const uint128_t &value2) noexcept
friend bool operator==(const uint128_t &value1, const uint256_t &value2) noexcept
friend uint256_t operator+(const uint256_t &value1, const T &value2) noexcept
uint256_t & operator+=(const T &value) noexcept
friend uint256_t operator>>(int8_t value1, const uint256_t &value2) noexcept
friend uint128_t & operator|=(uint128_t &value1, const uint256_t &value2) noexcept
uint256_t(uint256_t &&) noexcept=default
size_t bits() const noexcept
Get the count of bits.
friend uint256_t operator<<(int16_t value1, const uint256_t &value2) noexcept
friend uint256_t operator<<(bool value1, const uint256_t &value2) noexcept
friend uint256_t operator>>(int32_t value1, const uint256_t &value2) noexcept
uint256_t(const uint256_t &) noexcept=default
uint256_t & operator*=(const uint256_t &value) noexcept
friend bool operator&&(const uint256_t &value1, const T &value2) noexcept
friend uint256_t operator^(const uint256_t &value1, const uint128_t &value2) noexcept
friend T & operator+=(T &value1, const uint256_t &value2) noexcept
friend uint256_t operator-(const uint256_t &value1, const uint128_t &value2) noexcept
friend uint256_t operator<<(int64_t value1, const uint256_t &value2) noexcept
friend bool operator&&(const uint256_t &value1, const uint128_t &value2) noexcept
friend uint256_t operator>>(uint64_t value1, const uint256_t &value2) noexcept
friend uint256_t operator<<(int8_t value1, const uint256_t &value2) noexcept
friend bool operator&&(const T &value1, const uint256_t &value2) noexcept
uint256_t & operator^=(const T &value) noexcept
friend uint256_t operator>>(const uint256_t &value1, const T &value2) noexcept
friend uint128_t & operator>>=(uint128_t &value1, const uint256_t &value2) noexcept
friend uint256_t operator-(const T &value1, const uint256_t &value2) noexcept
friend uint256_t operator<<(const uint256_t &value1, const T &value2) noexcept
friend uint128_t & operator/=(uint128_t &value1, const uint256_t &value2)
uint256_t & operator>>=(const T &value) noexcept
friend uint256_t operator*(const T &value1, const uint256_t &value2) noexcept
friend uint256_t operator<<(uint32_t value1, const uint256_t &value2) noexcept
friend bool operator>(const uint256_t &value1, const T &value2) noexcept
friend uint256_t operator-(const uint256_t &value1, const T &value2) noexcept
uint256_t & operator*=(const T &value) noexcept
uint256_t & operator<<=(const uint256_t &value) noexcept
friend T & operator/=(T &value1, const uint256_t &value2)
uint256_t & operator|=(const T &value) noexcept
uint256_t operator-() const noexcept
friend uint256_t operator+(const uint256_t &value1, const uint128_t &value2) noexcept
friend uint256_t operator%(const T &value1, const uint256_t &value2)
uint256_t operator--(int) noexcept
friend bool operator>(const T &value1, const uint256_t &value2) noexcept
friend bool operator>=(const uint256_t &value1, const uint128_t &value2) noexcept
friend bool operator&&(const uint128_t &value1, const uint256_t &value2) noexcept
friend uint256_t operator/(const uint256_t &value1, const T &value2)
friend bool operator<(const uint256_t &value1, const T &value2) noexcept
friend T & operator&=(T &value1, const uint256_t &value2) noexcept
friend uint256_t operator|(const uint256_t &value1, const T &value2) noexcept
uint256_t & operator/=(const T &value)
friend bool operator>(const uint128_t &value1, const uint256_t &value2) noexcept
friend T & operator|=(T &value1, const uint256_t &value2) noexcept
friend bool operator||(const uint256_t &value1, const uint128_t &value2) noexcept
uint256_t & operator--() noexcept
friend bool operator<=(const T &value1, const uint256_t &value2) noexcept
uint256_t operator+() const noexcept
friend uint256_t operator*(const uint256_t &value1, const T &value2) noexcept
friend uint256_t operator^(const uint256_t &value1, const T &value2) noexcept
friend uint256_t operator+(const T &value1, const uint256_t &value2) noexcept
uint256_t & operator/=(const uint256_t &value)
friend bool operator>(const uint256_t &value1, const uint128_t &value2) noexcept
friend uint256_t operator>>(int64_t value1, const uint256_t &value2) noexcept
friend uint256_t operator|(const T &value1, const uint256_t &value2) noexcept
friend uint256_t operator%(const uint256_t &value1, const uint128_t &value2)
friend bool operator==(const T &value1, const uint256_t &value2) noexcept
uint128_t lower() const noexcept
Get the lower part of the 256-bit integer.
uint128_t upper() const noexcept
Get the upper part of the 256-bit integer.
uint256_t & operator^=(const uint256_t &value) noexcept
friend bool operator<(const T &value1, const uint256_t &value2) noexcept
friend bool operator<=(const uint256_t &value1, const uint128_t &value2) noexcept
friend uint256_t operator+(const uint128_t &value1, const uint256_t &value2) noexcept
std::wstring wstring(size_t base=10, size_t length=0) const
Get wide string from the current 128-bit integer.
friend T & operator*=(T &value1, const uint256_t &value2) noexcept
friend bool operator!=(const T &value1, const uint256_t &value2) noexcept
uint256_t & operator-=(const T &value) noexcept
friend T & operator^=(T &value1, const uint256_t &value2) noexcept
uint256_t & operator%=(const uint256_t &value)
friend uint256_t operator>>(uint32_t value1, const uint256_t &value2) noexcept
friend uint256_t operator<<(const uint128_t &value1, const uint256_t &value2) noexcept
friend uint256_t operator&(const T &value1, const uint256_t &value2) noexcept
friend uint128_t & operator+=(uint128_t &value1, const uint256_t &value2) noexcept
uint256_t & operator>>=(const uint256_t &value) noexcept
friend uint256_t operator>>(const uint128_t &value1, const uint256_t &value2) noexcept
friend uint256_t operator|(const uint128_t &value1, const uint256_t &value2) noexcept
friend T & operator%=(T &value1, const uint256_t &value2)
friend uint256_t operator%(const uint128_t &value1, const uint256_t &value2)
friend uint256_t operator<<(uint8_t value1, const uint256_t &value2) noexcept
friend uint256_t operator<<(uint16_t value1, const uint256_t &value2) noexcept
friend std::wistream & operator>>(std::wistream &is, uint256_t &value)
Input instance from the given wide input stream.
friend bool operator!=(const uint256_t &value1, const T &value2) noexcept
friend bool operator<(const uint256_t &value1, const uint128_t &value2) noexcept
friend bool operator<=(const uint128_t &value1, const uint256_t &value2) noexcept
friend uint256_t operator/(const T &value1, const uint256_t &value2)
uint256_t & operator|=(const uint256_t &value) noexcept
friend uint256_t operator|(const uint256_t &value1, const uint128_t &value2) noexcept
uint256_t & operator<<=(const T &value) noexcept
friend uint256_t operator-(const uint128_t &value1, const uint256_t &value2) noexcept
friend uint128_t & operator<<=(uint128_t &value1, const uint256_t &value2) noexcept
static std::pair< uint256_t, uint256_t > divmod(const uint256_t &x, const uint256_t &y)
Calculate quotient and remainder when dividing X by Y.
friend bool operator==(const uint256_t &value1, const T &value2) noexcept
friend T & operator<<=(T &value1, const uint256_t &value2) noexcept
friend uint256_t operator&(const uint256_t &value1, const uint128_t &value2) noexcept
friend uint256_t operator<<(int32_t value1, const uint256_t &value2) noexcept
friend bool operator>=(const uint128_t &value1, const uint256_t &value2) noexcept
friend uint256_t operator&(const uint256_t &value1, const T &value2) noexcept
friend bool operator||(const uint128_t &value1, const uint256_t &value2) noexcept
uint256_t & operator%=(const T &value)
friend bool operator==(const uint256_t &value1, const uint128_t &value2) noexcept
friend bool operator>=(const uint256_t &value1, const T &value2) noexcept
friend uint256_t operator>>(int16_t value1, const uint256_t &value2) noexcept
friend T & operator-=(T &value1, const uint256_t &value2) noexcept
friend uint128_t & operator-=(uint128_t &value1, const uint256_t &value2) noexcept
friend uint256_t operator/(const uint128_t &value1, const uint256_t &value2)
friend bool operator||(const uint256_t &value1, const T &value2) noexcept
uint256_t operator++(int) noexcept
friend bool operator||(const T &value1, const uint256_t &value2) noexcept
uint256_t & operator++() noexcept
friend bool operator<(const uint128_t &value1, const uint256_t &value2) noexcept
friend uint128_t & operator&=(uint128_t &value1, const uint256_t &value2) noexcept
friend uint256_t operator*(const uint128_t &value1, const uint256_t &value2) noexcept
friend bool operator>=(const T &value1, const uint256_t &value2) noexcept
uint256_t & operator+=(const uint256_t &value) noexcept
friend T & operator>>=(T &value1, const uint256_t &value2) noexcept
uint256_t & operator&=(const T &value) noexcept
friend uint256_t operator>>(uint16_t value1, const uint256_t &value2) noexcept
void swap(uint256_t &value) noexcept
Swap two instances.
friend uint128_t & operator*=(uint128_t &value1, const uint256_t &value2) noexcept
uint256_t operator~() const noexcept
friend uint256_t operator^(const T &value1, const uint256_t &value2) noexcept
friend uint256_t operator%(const uint256_t &value1, const T &value2)
uint256_t & operator&=(const uint256_t &value) noexcept
friend uint256_t operator&(const uint128_t &value1, const uint256_t &value2) noexcept
friend bool operator!=(const uint128_t &value1, const uint256_t &value2) noexcept
friend uint256_t operator>>(bool value1, const uint256_t &value2) noexcept
friend uint128_t & operator%=(uint128_t &value1, const uint256_t &value2)
friend uint256_t operator>>(uint8_t value1, const uint256_t &value2) noexcept
uint256_t & operator-=(const uint256_t &value) noexcept
friend uint256_t operator/(const uint256_t &value1, const uint128_t &value2)
friend bool operator<=(const uint256_t &value1, const T &value2) noexcept
friend uint128_t & operator^=(uint128_t &value1, const uint256_t &value2) noexcept
bool operator!() const noexcept
C++ Common project definitions.
Unsigned 128-bit integer type definition.
Unsigned 256-bit integer type inline implementation.