From 100c3315be5faafbdaa3fdcc5f302a5d599f0cd0 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 e2df48825..6a2e95e9d 100644 --- a/src/redis.c +++ b/src/redis.c @@ -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); } }