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 authored and antirez committed 2014-08-18 11:11:00 +02:00
1 parent 0a98b21f65
commit 100c3315be
1 file changed
+9
+9
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);
}
}