Skip to content

Commit

Permalink
Merge pull request #91 from anoma/main
Browse files Browse the repository at this point in the history
Add case fod DivideZ in halo2's evaluate_expr
  • Loading branch information
lopeetall authored May 16, 2023
2 parents e11fbcd + e104589 commit 1e5d5b5
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/halo2/synth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ where
Expr::Infix(InfixOp::Divide, a, b) => {
evaluate_expr(&a, defs, assigns) * evaluate_expr(&b, defs, assigns).invert().unwrap()
}
Expr::Infix(InfixOp::DivideZ, a, b) => {
let divisor = evaluate_expr(&b, defs, assigns);
if divisor.is_zero().into() {
0.into()
} else {
evaluate_expr(&a, defs, assigns) * divisor.invert().unwrap()
}
}
Expr::Infix(InfixOp::IntDivide, a, b) => {
let op1 = BigUint::from_bytes_le(evaluate_expr(&a, defs, assigns).to_repr().as_ref());
let op2 = BigUint::from_bytes_le(evaluate_expr(&b, defs, assigns).to_repr().as_ref());
Expand Down

0 comments on commit 1e5d5b5

Please sign in to comment.