Extend range of bytesToHuman to TB and PB

Also adds a fallthrough case for when given
large values (like overflow numbers of 2^64 by mistake).

Closes #858
This commit is contained in:
David Palm 2013-01-02 20:22:26 +01:00 committed by antirez
parent 0a98b21f65
commit 100c3315be

View File

@ -2547,6 +2547,15 @@ void bytesToHuman(char *s, unsigned long long n) {
} else if (n < (1024LL*1024*1024*1024)) {
d = (double)n/(1024LL*1024*1024);
sprintf(s,"%.2fG",d);
} else if (n < (1024LL*1024*1024*1024*1024)) {
d = (double)n/(1024LL*1024*1024*1024);
sprintf(s,"%.2fT",d);
} else if (n < (1024LL*1024*1024*1024*1024*1024)) {
d = (double)n/(1024LL*1024*1024*1024*1024);
sprintf(s,"%.2fP",d);
} else {
/* Let's hope we never need this */
sprintf(s,"%lluB",n);
}
}