We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent eae05f2 commit 789e7e3Copy full SHA for 789e7e3
src/lib/increment.js
@@ -25,12 +25,14 @@ module.exports = function incrementNumeric(x, delta) {
25
// Note 2:
26
// now we may also consider rounding to cover few more edge cases
27
// e.g. 0.3 * 3 = 0.8999999999999999
28
- var lenDt = String(delta).length;
29
- var lenX0 = String(x).length;
30
var lenX1 = String(newX).length;
+ if(lenX1 > 16) {
+ var lenDt = String(delta).length;
31
+ var lenX0 = String(x).length;
32
- if(lenX1 >= lenX0 + lenDt) { // likely a rounding error!
33
- newX = +parseFloat(newX).toPrecision(12);
+ if(lenX1 >= lenX0 + lenDt) { // likely a rounding error!
34
+ newX = +parseFloat(newX).toPrecision(12);
35
+ }
36
}
37
38
return newX;
0 commit comments