forked from svrjs/svrjs
Fixes bug in the sizify function
This commit is contained in:
parent
ab69abf2da
commit
953c95f485
1 changed files with 1 additions and 1 deletions
2
svr.js
2
svr.js
|
@ -504,7 +504,7 @@ function sizify(bytes, addI) {
|
||||||
if (bytes == 0) return "0";
|
if (bytes == 0) return "0";
|
||||||
if (bytes < 0) bytes = -bytes;
|
if (bytes < 0) bytes = -bytes;
|
||||||
var prefixes = ["", "K", "M", "G", "T", "P", "E", "Z", "Y", "R", "Q"];
|
var prefixes = ["", "K", "M", "G", "T", "P", "E", "Z", "Y", "R", "Q"];
|
||||||
var prefixIndex = Math.floor(Math.log2 ? Math.log2(bytes) / 10 : (Math.log(bytes) / Math.log(2) * 10));
|
var prefixIndex = Math.floor(Math.log2 ? Math.log2(bytes) / 10 : (Math.log(bytes) / (Math.log(2) * 10)));
|
||||||
if (prefixIndex >= prefixes.length - 1) prefixIndex = prefixes.length - 1;
|
if (prefixIndex >= prefixes.length - 1) prefixIndex = prefixes.length - 1;
|
||||||
var prefixIndexTranslated = Math.pow(2, 10 * prefixIndex);
|
var prefixIndexTranslated = Math.pow(2, 10 * prefixIndex);
|
||||||
var decimalPoints = 2 - Math.floor(Math.log10 ? Math.log10(bytes / prefixIndexTranslated) : (Math.log(bytes / prefixIndexTranslated) / Math.log(10)));
|
var decimalPoints = 2 - Math.floor(Math.log10 ? Math.log10(bytes / prefixIndexTranslated) : (Math.log(bytes / prefixIndexTranslated) / Math.log(10)));
|
||||||
|
|
Reference in a new issue