Skip to content

Commit

Permalink
Extend range of bytesToHuman to TB and PB
Browse files Browse the repository at this point in the history
Also adds a fallthrough case for when given
large values (like overflow numbers of 2^64 by mistake).

Closes #858
  • Loading branch information
dvdplm authored and antirez committed Aug 18, 2014
1 parent 0a98b21 commit 100c331
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/redis.c
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit 100c331

Please sign in to comment.