Skip to content

Commit

Permalink
Fixed FixedNumber rounding for non-default formats (#1629).
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmoo committed May 31, 2021
1 parent 470551e commit 8681cd5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/bignumber/src.ts/fixednumber.ts
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 8681cd5

Please sign in to comment.