Skip to content

Commit

Permalink
refactor: Refine numeric comparison in prop_lesser function
Browse files Browse the repository at this point in the history
- add a direct comparison from #738
  • Loading branch information
huitseeker committed Nov 8, 2023
1 parent f5c1fef commit 7220306
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/num.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,9 +472,13 @@ mod tests {
overflow_boundary -= x2;
x1 > overflow_boundary
};
let diff = Num::Scalar(x1 - x2);
if !underflow && !overflow {
assert_eq!(a.is_less_than(&b), Num::Scalar(x1 - x2).is_negative());
assert_eq!(a.is_less_than(&b), diff.is_negative());
}

let same_sign = !(x1.is_negative() ^ x2.is_negative());
assert_eq!(a.is_less_than(&b), (same_sign && diff.is_negative()) || (!same_sign && a.is_negative()));
},
(Num::U64(x1), Num::Scalar(x2)) if !x2.is_negative() => {
assert_eq!(a.is_less_than(&b), Scalar::from(x1) < x2);
Expand Down

0 comments on commit 7220306

Please sign in to comment.