diff --git a/src/lib/provable/int.ts b/src/lib/provable/int.ts index e919b17a9e..15c64c6249 100644 --- a/src/lib/provable/int.ts +++ b/src/lib/provable/int.ts @@ -1147,14 +1147,22 @@ class Int64 extends CircuitValue implements BalanceChange { return Int64.create(UInt64.from(obj.magnitude), Sign.fromValue(obj.sgn)); } + /** + * Turns the {@link Int64} into a {@link BigInt}. + */ + toBigint() { + let abs = this.magnitude.toBigInt(); + let sgn = this.sgn.isPositive().toBoolean() ? 1n : -1n; + return sgn * abs; + } + /** * Turns the {@link Int64} into a string. */ toString() { - let abs = this.magnitude.toString(); - let sgn = this.isPositive().toBoolean() || abs === '0' ? '' : '-'; - return sgn + abs; + return this.toBigint().toString(); } + isConstant() { return this.magnitude.value.isConstant() && this.sgn.isConstant(); }