Skip to content

Commit

Permalink
fix int64 mod when the input is negative and result = 0
Browse files Browse the repository at this point in the history
  • Loading branch information
mitschabaude committed Aug 21, 2024
1 parent 0617674 commit 78175fe
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/lib/provable/int.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1334,7 +1334,11 @@ class Int64 extends CircuitValue implements BalanceChange {
let isNonNegative = this.magnitude
.equals(UInt64.zero)
.or(this.sgn.isPositive());
rest = Provable.if(isNonNegative, rest, y_.value.sub(rest));
rest = Provable.if(
isNonNegative.or(rest.equals(0)),
rest,
y_.value.sub(rest)
);
return new Int64(new UInt64(rest.value));
}

Expand Down

0 comments on commit 78175fe

Please sign in to comment.