Skip to content

Commit

Permalink
Merge pull request #644 from noobaa/guy_038
Browse files Browse the repository at this point in the history
Fix human_offset to work for offsets over 4 GB
  • Loading branch information
guymguym committed Dec 10, 2015
2 parents f6f25c8 + 20be407 commit d7f0dbc
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/util/size_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,29 +133,29 @@ function human_offset(offset) {
} else {
peta = 0;
if (offset < 0) {
n = (-offset) | 0;
n = -offset;
sign = '-';
} else {
n = offset | 0;
n = offset;
sign = '';
}
}

// always include the lowest offset unit
res = (n & 0x3FF) + '';
n >>>= 10;
res = (n % 1024) + '';
n = Math.floor(n / 1024);

i = 1;
while (n) {
res = (n & 0x3FF) + SIZE_UNITS[i] + '_' + res;
n >>>= 10;
res = (n % 1024) + SIZE_UNITS[i] + '_' + res;
n = Math.floor(n / 1024);
i++;
}

i = 5;
while (peta) {
res = (peta & 0x3FF) + SIZE_UNITS[i] + '_' + res;
peta >>>= 10;
res = (peta % 1024) + SIZE_UNITS[i] + '_' + res;
peta = Math.floor(peta / 1024);
i++;
}

Expand Down

0 comments on commit d7f0dbc

Please sign in to comment.