Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ebb63c8

Browse files
committed
avoid rounding big numbers in the second step
1 parent eba1cb4 commit ebb63c8

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/lib/increment.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,13 @@ module.exports = function incrementNumeric(x, delta) {
3131
var lenX0 = String(x).length;
3232

3333
if(lenX1 >= lenX0 + lenDt) { // likely a rounding error!
34-
newX = +parseFloat(newX).toPrecision(12);
34+
var s = parseFloat(newX).toPrecision(12);
35+
if(
36+
s.indexOf('e') === -1 ||
37+
s.indexOf('e-') !== -1
38+
) {
39+
newX = +s;
40+
}
3541
}
3642
}
3743

0 commit comments

Comments
 (0)