File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
src/components/NumericDisplay Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -40,11 +40,16 @@ function formatNumber(number = 0, shortForm = true) {
40
40
) . toString ( ) ; //return number rounded to nearest integer
41
41
} else {
42
42
//if number is 1 thousand or more
43
- const mantissa = parseFloat ( number ) / Math . pow ( 10 , exponent3 ) ; //get the mantissa value from 1 to 999
43
+ const mantissa = parseFloat ( number . toString ( ) ) / Math . pow ( 10 , exponent3 ) ; //get the mantissa value from 1 to 999
44
44
const roundedNumber = mantissa . toPrecision ( 3 ) ; //round number to 3 significant figures
45
45
return (
46
- Math . min ( 999 , Math . max ( - 999 , Number ( roundedNumber ) ) ) . toPrecision ( 3 ) +
47
- prefixes [ exponent3 / 3 ]
46
+ Math . min (
47
+ 999 ,
48
+ Math . max (
49
+ - 999 ,
50
+ Number ( Math . abs ( roundedNumber ) * Math . sign ( roundedNumber ) ) ,
51
+ ) ,
52
+ ) . toPrecision ( 3 ) + prefixes [ exponent3 / 3 ]
48
53
) ; //return coefficient of engineering notation with numeric prefix
49
54
}
50
55
} else {
You can’t perform that action at this time.
0 commit comments