26 static_assert(BITS / 32 > 0 && BITS % 32 == 0,
"Template parameter BITS must be a positive multiple of 32.");
27 static constexpr
int WIDTH = BITS / 32;
33 for (
int i = 0; i <
WIDTH; i++)
39 for (
int i = 0; i <
WIDTH; i++)
45 for (
int i = 0; i <
WIDTH; i++)
52 pn[0] = (
unsigned int)b;
53 pn[1] = (
unsigned int)(b >> 32);
54 for (
int i = 2; i <
WIDTH; i++)
61 for (
int i = 0; i <
WIDTH; i++)
69 for (
int i = 0; i <
WIDTH; i++)
79 pn[0] = (
unsigned int)b;
80 pn[1] = (
unsigned int)(b >> 32);
81 for (
int i = 2; i <
WIDTH; i++)
88 for (
int i = 0; i <
WIDTH; i++)
95 for (
int i = 0; i <
WIDTH; i++)
102 for (
int i = 0; i <
WIDTH; i++)
109 pn[0] ^= (
unsigned int)b;
110 pn[1] ^= (
unsigned int)(b >> 32);
116 pn[0] |= (
unsigned int)b;
117 pn[1] |= (
unsigned int)(b >> 32);
127 for (
int i = 0; i <
WIDTH; i++)
129 uint64_t n = carry +
pn[i] + b.
pn[i];
130 pn[i] = n & 0xffffffff;
166 while (i <
WIDTH && ++
pn[i] == 0)
197 bool EqualTo(uint64_t b)
const;
241 return memcmp(a.
pn, b.
pn,
sizeof(a.
pn)) == 0;
245 return memcmp(a.
pn, b.
pn,
sizeof(a.
pn)) != 0;
281 unsigned int bits()
const;
285 static_assert(
WIDTH >= 2,
"Assertion WIDTH >= 2 failed (WIDTH = BITS / 32). BITS is a template parameter.");
286 return pn[0] | (uint64_t)
pn[1] << 32;
Definition: arith_uint256.h:24
base_uint & operator=(const base_uint &b)
Definition: arith_uint256.h:43
base_uint operator~() const
Definition: arith_uint256.h:58
uint32_t pn[WIDTH]
Definition: arith_uint256.h:28
base_uint & operator=(uint64_t b)
Definition: arith_uint256.h:77
int CompareTo(const base_uint &b) const
Definition: arith_uint256.cpp:97
base_uint & operator+=(uint64_t b64)
Definition: arith_uint256.h:142
base_uint operator--(int)
Definition: arith_uint256.h:188
unsigned int size() const
Definition: arith_uint256.h:272
base_uint(uint64_t b)
Definition: arith_uint256.h:50
base_uint & operator--()
Definition: arith_uint256.h:179
friend bool operator!=(const base_uint &a, const base_uint &b)
Definition: arith_uint256.h:243
base_uint & operator^=(uint64_t b)
Definition: arith_uint256.h:107
base_uint & operator>>=(unsigned int shift)
Definition: arith_uint256.cpp:24
base_uint & operator++()
Definition: arith_uint256.h:162
friend base_uint operator-(const base_uint &a, const base_uint &b)
Definition: arith_uint256.h:203
base_uint(const base_uint &b)
Definition: arith_uint256.h:37
friend base_uint operator*(const base_uint &a, const base_uint &b)
Definition: arith_uint256.h:207
static constexpr int WIDTH
Definition: arith_uint256.h:27
base_uint & operator&=(const base_uint &b)
Definition: arith_uint256.h:93
friend base_uint operator<<(const base_uint &a, int shift)
Definition: arith_uint256.h:231
friend base_uint operator&(const base_uint &a, const base_uint &b)
Definition: arith_uint256.h:219
friend bool operator<(const base_uint &a, const base_uint &b)
Definition: arith_uint256.h:251
base_uint & operator-=(const base_uint &b)
Definition: arith_uint256.h:136
base_uint & operator+=(const base_uint &b)
Definition: arith_uint256.h:124
friend bool operator==(const base_uint &a, uint64_t b)
Definition: arith_uint256.h:263
base_uint operator-() const
Definition: arith_uint256.h:66
friend base_uint operator>>(const base_uint &a, int shift)
Definition: arith_uint256.h:227
friend bool operator>=(const base_uint &a, const base_uint &b)
Definition: arith_uint256.h:255
base_uint & operator*=(uint32_t b32)
Definition: arith_uint256.cpp:41
friend base_uint operator|(const base_uint &a, const base_uint &b)
Definition: arith_uint256.h:215
bool EqualTo(uint64_t b) const
Definition: arith_uint256.cpp:109
friend base_uint operator*(const base_uint &a, uint32_t b)
Definition: arith_uint256.h:235
friend bool operator==(const base_uint &a, const base_uint &b)
Definition: arith_uint256.h:239
base_uint()
Definition: arith_uint256.h:31
base_uint & operator|=(const base_uint &b)
Definition: arith_uint256.h:100
base_uint & operator-=(uint64_t b64)
Definition: arith_uint256.h:150
friend bool operator!=(const base_uint &a, uint64_t b)
Definition: arith_uint256.h:267
friend base_uint operator/(const base_uint &a, const base_uint &b)
Definition: arith_uint256.h:211
friend base_uint operator^(const base_uint &a, const base_uint &b)
Definition: arith_uint256.h:223
friend bool operator>(const base_uint &a, const base_uint &b)
Definition: arith_uint256.h:247
friend bool operator<=(const base_uint &a, const base_uint &b)
Definition: arith_uint256.h:259
base_uint & operator|=(uint64_t b)
Definition: arith_uint256.h:114
double getdouble() const
Definition: arith_uint256.cpp:123
base_uint & operator<<=(unsigned int shift)
Definition: arith_uint256.cpp:7
base_uint operator++(int)
Definition: arith_uint256.h:171
base_uint & operator^=(const base_uint &b)
Definition: arith_uint256.h:86
base_uint & operator/=(const base_uint &b)
Definition: arith_uint256.cpp:70
uint64_t GetLow64() const
Definition: arith_uint256.h:283
friend base_uint operator+(const base_uint &a, const base_uint &b)
Definition: arith_uint256.h:199
unsigned int bits() const
Definition: arith_uint256.cpp:134
Definition: arith_uint256.h:15
uint_error(const std::string &str)
Definition: arith_uint256.h:17