Apply suggestions from code review of branch allow-zero
Co-authored-by: Julian Stirling <julian@julianstirling.co.uk>
This commit is contained in:
parent
25a839bf88
commit
dbe8634041
1 changed files with 1 additions and 1 deletions
|
|
@ -347,7 +347,7 @@ export default {
|
||||||
|
|
||||||
// Rounding to about 5 sig figs to stop weird javascript rounding.
|
// Rounding to about 5 sig figs to stop weird javascript rounding.
|
||||||
const absVal = Math.abs(newValue);
|
const absVal = Math.abs(newValue);
|
||||||
const magnitude = absVal > 0 ? Math.floor(Math.log10(absVal)) : 0;
|
const magnitude = absVal > Number.EPSILON ? Math.floor(Math.log10(absVal)) : 0;
|
||||||
const factor = 10 ** -(Math.floor(magnitude) - 4);
|
const factor = 10 ** -(Math.floor(magnitude) - 4);
|
||||||
this.internalValue = Math.round(newValue * factor) / factor;
|
this.internalValue = Math.round(newValue * factor) / factor;
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue