Skip to content
This repository has been archived by the owner on Nov 8, 2024. It is now read-only.

Commit

Permalink
Merge pull request #907 from vegaprotocol/fix/handle-negaitve-positio…
Browse files Browse the repository at this point in the history
…n-decimal-places

fix: handle negative position decimals in formatter
  • Loading branch information
mattrussell36 authored Aug 4, 2023
2 parents 596793b + 8fbf2f4 commit 73c75aa
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/util/misc/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ export const formatter = (value: number, fractionDigits: number = 5) => {
return "-";
}

// positional decimal places can be negative.
// e.g. -3 means that the smallest order and position is of size 1000
// in that case we dont need fractionDigits so we can set it to 0
// otherwise new Intl.NumberFormat will throw
fractionDigits = Math.max(0, fractionDigits);

return new Intl.NumberFormat("en-GB", {
maximumFractionDigits: fractionDigits,
minimumFractionDigits: fractionDigits,
Expand Down

0 comments on commit 73c75aa

Please sign in to comment.