51 auto hi_operand =
static_cast<uint256_t>(a_decomp.hi) *
static_cast<uint256_t>(b_decomp.hi);
127 if (
a.get_tag() !=
b.get_tag()) {
129 throw AluException(
"EQ, Tag mismatch between operands.");
141 if (
a.get_tag() !=
b.get_tag()) {
143 throw AluException(
"LT, Tag mismatch between operands.");
155 if (
a.get_tag() !=
b.get_tag()) {
157 throw AluException(
"LT, Tag mismatch between operands.");
185 auto b_num =
static_cast<uint128_t>(
b.as_ff());
187 bool overflow = b_num > tag_bits;
188 uint8_t a_lo_bits = overflow ? tag_bits : tag_bits -
static_cast<uint8_t
>(b_num);
190 overflow ? b_num - tag_bits :
static_cast<uint128_t>(
a.as_ff()) % (
static_cast<uint128_t>(1) << a_lo_bits);
193 overflow ? tag_bits :
static_cast<uint8_t
>(b_num));
202 }
catch (
const std::exception& e) {
213 auto b_num =
static_cast<uint128_t>(
b.as_ff());
215 bool overflow = b_num > tag_bits;
216 uint8_t a_lo_bits = overflow ? tag_bits :
static_cast<uint8_t
>(b_num);
218 overflow ? b_num - tag_bits :
static_cast<uint128_t>(
a.as_ff()) % (
static_cast<uint128_t>(1) << a_lo_bits);
221 overflow ? tag_bits : tag_bits -
static_cast<uint8_t
>(b_num));
230 }
catch (
const std::exception& e) {
249 a_lo = decomposition.
lo;
static TaggedValue from_tag_truncating(ValueTag tag, FF value)
static TaggedValue from_tag(ValueTag tag, FF value)
MemoryValue lte(const MemoryValue &a, const MemoryValue &b) override
MemoryValue fdiv(const MemoryValue &a, const MemoryValue &b) override
MemoryValue truncate(const FF &a, MemoryTag dst_tag) override
MemoryValue eq(const MemoryValue &a, const MemoryValue &b) override
MemoryValue lt(const MemoryValue &a, const MemoryValue &b) override
MemoryValue shl(const MemoryValue &a, const MemoryValue &b) override
MemoryValue add(const MemoryValue &a, const MemoryValue &b) override
MemoryValue sub(const MemoryValue &a, const MemoryValue &b) override
FieldGreaterThanInterface & field_gt
MemoryValue mul(const MemoryValue &a, const MemoryValue &b) override
MemoryValue shr(const MemoryValue &a, const MemoryValue &b) override
EventEmitterInterface< AluEvent > & events
MemoryValue op_not(const MemoryValue &a) override
GreaterThanInterface & greater_than
MemoryValue div(const MemoryValue &a, const MemoryValue &b) override
virtual U256Decomposition canon_dec(const FF &a)=0
virtual bool gt(const FF &a, const FF &b)=0
U256Decomposition decompose(const uint256_t &x)
uint8_t get_tag_bits(ValueTag tag)
uint256_t get_tag_max_value(ValueTag tag)
unsigned __int128 uint128_t