Fixed off by one bug. List length is 1 larger than the index of the last

element.
This commit is contained in:
Roland van Laar 2012-02-26 22:09:21 +01:00
parent aae0d990ca
commit 2a351f4456
1 changed files with 1 additions and 1 deletions

View File

@ -455,7 +455,7 @@ function humanFileSize(size) {
// Calculate Log with base 1024: size = 1024 ** order
order = Math.floor(Math.log(size) / Math.log(1024));
// Stay in range of the byte sizes that are defined
order = Math.min(humanList.length, order);
order = Math.min(humanList.length - 1, order);
readableFormat = humanList[order];
relativeSize = (size / Math.pow(1024, order)).toFixed(1);
if(relativeSize.substr(relativeSize.length-2,2)=='.0'){