From ea96304806d0e0a1669085cf854075487d7b91fb Mon Sep 17 00:00:00 2001 From: Richard Moore Date: Mon, 31 May 2021 17:37:56 -0400 Subject: [PATCH] Fixed FixedNumber rounding for non-default formats (#1629). --- packages/bignumber/src.ts/fixednumber.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/bignumber/src.ts/fixednumber.ts b/packages/bignumber/src.ts/fixednumber.ts index 7bd9ffd9e6..15279424bd 100644 --- a/packages/bignumber/src.ts/fixednumber.ts +++ b/packages/bignumber/src.ts/fixednumber.ts @@ -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 {