Apply suggestions from code review of branch allow-zero

Co-authored-by: Julian Stirling <julian@julianstirling.co.uk>
This commit is contained in:
Joe Knapper 2026-02-24 12:36:30 +00:00
parent 25a839bf88
commit dbe8634041

View file

@ -347,7 +347,7 @@ export default {
// Rounding to about 5 sig figs to stop weird javascript rounding.
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);
this.internalValue = Math.round(newValue * factor) / factor;
},