Skip to content
This repository has been archived by the owner on Oct 12, 2021. It is now read-only.

Commit

Permalink
Fixed FixedNumber rounding for non-default formats (ethers-io#1629).
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmoo authored and pull[bot] committed Jun 4, 2021
1 parent 709bb2d commit b17594a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/bignumber/src.ts/fixednumber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,10 @@ export class FixedNumber {

if (comps[1].length <= decimals) { return this; }

const factor = FixedNumber.from("1" + zeros.substring(0, decimals));
return this.mulUnsafe(factor).addUnsafe(BUMP).floor().divUnsafe(factor);
const factor = FixedNumber.from("1" + zeros.substring(0, decimals), this.format);
const bump = BUMP.toFormat(this.format);

return this.mulUnsafe(factor).addUnsafe(bump).floor().divUnsafe(factor);
}

isZero(): boolean {
Expand Down

0 comments on commit b17594a

Please sign in to comment.