From 8c0743d80e5513be4ca4204e693ed99b0802fb5e Mon Sep 17 00:00:00 2001 From: David Palm Date: Wed, 2 Jan 2013 20:22:26 +0100 Subject: [PATCH] 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 --- src/redis.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/redis.c b/src/redis.c index 89d276bf..2b3cf154 100644 --- a/src/redis.c +++ b/src/redis.c @@ -2392,6 +2392,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); } } -- GitLab