Skip to content

Commit

Permalink
🐛 fix: result with unexpected dot
Browse files Browse the repository at this point in the history
  • Loading branch information
Leslie-Wong-H committed Sep 2, 2021
1 parent 17db611 commit 92d1684
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions jsbi-calculator.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class BigDecimal {
)
);
}
multiple(num) {
multiply(num) {
return BigDecimal._divRound(
JSBI.multiply(this._n, new BigDecimal(num)._n),
BigDecimal.SHIFT
Expand All @@ -72,11 +72,11 @@ class BigDecimal {
}
toString() {
const s = this._n.toString().padStart(BigDecimal.DECIMALS + 1, "0");
return (
let r =
s.slice(0, -BigDecimal.DECIMALS) +
"." +
s.slice(-BigDecimal.DECIMALS).replace(/\.?0+$/, "")
);
s.slice(-BigDecimal.DECIMALS).replace(/\.?0+$/, "");
return r.slice(-1) === "." ? r.slice(0, -1) : r;
}
}

Expand Down

0 comments on commit 92d1684

Please sign in to comment.