14#include "../uint256/uint256.hpp"
15#include "barretenberg/common/assert.hpp"
16#include "barretenberg/common/throw_or_abort.hpp"
23template <
class base_u
int>
class uintx {
25 constexpr uintx(
const uint64_t data = 0)
30 constexpr uintx(
const base_uint input_lo)
35 constexpr uintx(
const base_uint input_lo,
const base_uint input_hi)
45 constexpr uintx(
uintx&& other)
noexcept =
default;
47 static constexpr size_t length() {
return 2 * base_uint::length(); }
48 constexpr uintx& operator=(
const uintx& other) =
default;
49 constexpr uintx& operator=(
uintx&& other)
noexcept =
default;
51 constexpr ~uintx() =
default;
52 explicit constexpr operator bool()
const {
return static_cast<bool>(lo.data[0]); };
53 explicit constexpr operator uint8_t()
const {
return static_cast<uint8_t
>(lo.data[0]); };
54 explicit constexpr operator uint16_t()
const {
return static_cast<uint16_t
>(lo.data[0]); };
55 explicit constexpr operator uint32_t()
const {
return static_cast<uint32_t
>(lo.data[0]); };
56 explicit constexpr operator uint64_t()
const {
return static_cast<uint64_t
>(lo.data[0]); };
58 explicit constexpr operator base_uint()
const {
return lo; }
60 [[nodiscard]]
constexpr bool get_bit(uint64_t bit_index)
const;
61 [[nodiscard]]
constexpr uint64_t get_msb()
const;
62 constexpr uintx slice(uint64_t start, uint64_t end)
const;
64 constexpr uintx operator+(
const uintx& other)
const;
65 constexpr uintx operator-(
const uintx& other)
const;
66 constexpr uintx operator-()
const;
68 constexpr uintx operator*(
const uintx& other)
const;
69 constexpr uintx operator/(
const uintx& other)
const;
70 constexpr uintx operator%(
const uintx& other)
const;
72 constexpr std::pair<uintx, uintx> mul_extended(
const uintx& other)
const;
74 constexpr uintx operator>>(uint64_t other)
const;
75 constexpr uintx operator<<(uint64_t other)
const;
77 constexpr uintx operator&(
const uintx& other)
const;
78 constexpr uintx operator^(
const uintx& other)
const;
79 constexpr uintx operator|(
const uintx& other)
const;
80 constexpr uintx operator~()
const;
82 constexpr bool operator==(
const uintx& other)
const;
83 constexpr bool operator!=(
const uintx& other)
const;
84 constexpr bool operator!()
const;
86 constexpr bool operator>(
const uintx& other)
const;
87 constexpr bool operator<(
const uintx& other)
const;
88 constexpr bool operator>=(
const uintx& other)
const;
89 constexpr bool operator<=(
const uintx& other)
const;
91 constexpr uintx& operator+=(
const uintx& other)
93 *
this = *
this + other;
96 constexpr uintx& operator-=(
const uintx& other)
98 *
this = *
this - other;
101 constexpr uintx& operator*=(
const uintx& other)
103 *
this = *
this * other;
106 constexpr uintx& operator/=(
const uintx& other)
108 *
this = *
this / other;
111 constexpr uintx& operator%=(
const uintx& other)
113 *
this = *
this % other;
117 constexpr uintx& operator++()
122 constexpr uintx& operator--()
128 constexpr uintx& operator&=(
const uintx& other)
130 *
this = *
this & other;
133 constexpr uintx& operator^=(
const uintx& other)
135 *
this = *
this ^ other;
138 constexpr uintx& operator|=(
const uintx& other)
140 *
this = *
this | other;
144 constexpr uintx& operator>>=(
const uint64_t other)
146 *
this = *
this >> other;
149 constexpr uintx& operator<<=(
const uint64_t other)
151 *
this = *
this << other;
161 constexpr std::pair<uintx, uintx> divmod(
const uintx& b)
const;
164template <
typename B,
typename Params>
inline void read(B& it,
uintx<Params>& value)
166 using serialize::read;
174template <
typename B,
typename Params>
inline void write(B& it,
uintx<Params> const& value)
176 using serialize::write;
181template <
class base_u
int>
inline std::ostream& operator<<(std::ostream& os,
uintx<base_uint> const& a)
183 os << a.lo <<
", " << a.hi << std::endl;
192#include "./uintx_impl.hpp"
constexpr uintx unsafe_invmod(const uintx &modulus) const
Definition: uintx_impl.hpp:65
constexpr uintx invmod(const uintx &modulus) const
Definition: uintx_impl.hpp:97
constexpr uintx slice(uint64_t start, uint64_t end) const
Definition: uintx_impl.hpp:117
Definition: field2_declarations.hpp:6