Skip to content

Commit

Permalink
Minor code simplification (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
caub authored and sindresorhus committed Apr 24, 2017
1 parent 0d17795 commit ed4f51e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -16,7 +16,7 @@ module.exports = num => {
return (neg ? '-' : '') + num + ' B';
}

const exponent = Math.min(Math.floor(Math.log(num) / Math.log(1000)), UNITS.length - 1);
const exponent = Math.min(Math.floor(Math.log10(num) / 3), UNITS.length - 1);
const numStr = Number((num / Math.pow(1000, exponent)).toPrecision(3));
const unit = UNITS[exponent];

Expand Down

0 comments on commit ed4f51e

Please sign in to comment.