From d06ea3708d12e3e87fa26441715ac47f6dc63032 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Thu, 3 Sep 2015 20:36:44 -0500 Subject: Make human_readable() handle base 1024 units without floating point. Rounds correctly via brute force, displayed digits are decimal even when working with powers of 2, shows at most 3 significant (decimal) digits. (So no "1023M" nonsense, that's 1.0G.) --- lib/lib.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'lib/lib.h') diff --git a/lib/lib.h b/lib/lib.h index 17a4a974..41f38d1b 100644 --- a/lib/lib.h +++ b/lib/lib.h @@ -177,12 +177,14 @@ void replace_tempfile(int fdin, int fdout, char **tempname); void crc_init(unsigned int *crc_table, int little_endian); void base64_init(char *p); int yesno(char *prompt, int def); -#define HR_SPACE 1 -#define HR_B 2 -int human_readable(char *buf, unsigned long long num, int style); int qstrcmp(const void *a, const void *b); int xpoll(struct pollfd *fds, int nfds, int timeout); +#define HR_SPACE 1 +#define HR_B 2 +#define HR_SI 4 +int human_readable(char *buf, unsigned long long num, int style); + // interestingtimes.c int xgettty(void); int terminal_size(unsigned *xx, unsigned *yy); -- cgit v1.2.3