Skip to content

Commit

Permalink
Fix rounding bug
Browse files Browse the repository at this point in the history
This solves the “1.005” problem.

More infos about the
[solution](http://stackoverflow.com/questions/11832914/round-to-at-most-
2-decimal-places-in-javascript#answer-18358056).
  • Loading branch information
indrimuska committed May 6, 2015
1 parent e1630bc commit a952fe9
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions jquery.number.js
Original file line number Diff line number Diff line change
@@ -746,8 +746,7 @@
var n = !isFinite(+number) ? 0 : +number,
s = '',
toFixedFix = function (n, decimals) {
var k = Math.pow(10, decimals);
return '' + Math.round(n * k) / k;
return '' + (+(Math.round(n + 'e+' + decimals) + 'e-' + decimals));
};

// Fix for IE parseFloat(0.55).toFixed(0) = 0;
2 changes: 1 addition & 1 deletion jquery.number.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a952fe9

Please sign in to comment.