Skip to content

Commit

Permalink
Compare floating-point numbers directly instead of using unnecessary …
Browse files Browse the repository at this point in the history
…division.
  • Loading branch information
jcopperfield committed Feb 19, 2018
1 parent e951ab2 commit 48a9d92
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/core.helpers.js
Expand Up @@ -163,7 +163,7 @@ module.exports = function(Chart) {
// Check for whole powers of 10,
// which due to floating point rounding error should be corrected.
var powerOf10 = Math.round(exponent);
var isPowerOf10 = (x / Math.pow(10, powerOf10)) === 1;
var isPowerOf10 = x === Math.pow(10, powerOf10);

return isPowerOf10 ? powerOf10 : exponent;
};
Expand Down

0 comments on commit 48a9d92

Please sign in to comment.