Skip to content

Commit 94c0a95

Browse files
committed
Fix display numeric values less than 1 thousand
1 parent c906202 commit 94c0a95

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/components/NumericDisplay/NumericDisplay.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ function formatNumber(number = 0, shortForm = true) {
3434
]; //numeric prefixes
3535
if (Math.abs(number) < 1000) {
3636
//if number is less than 1 thousand
37-
return Math.round(number).toString(); //return number rounded to nearest integer
37+
return Math.min(
38+
999,
39+
Math.max(-999, Math.round(Math.abs(number) * Math.sign(number))),
40+
).toString(); //return number rounded to nearest integer
3841
} else {
3942
//if number is 1 thousand or more
4043
const roundedNumber = number.toPrecision(3); //round number to 3 significant figures

0 commit comments

Comments
 (0)