diff options
author | Guillem Jover <guillem@hadrons.org> | 2008-06-13 05:25:57 +0300 |
---|---|---|
committer | Guillem Jover <guillem@hadrons.org> | 2008-06-13 05:25:57 +0300 |
commit | acb577d6c150370ea17fe5a07bd1361bfa4d18e2 (patch) | |
tree | 486f40c191924b2a88bdd7b89e5d84dc19c1dabc /src | |
parent | 0be77c90b57f7c1af8796701aa294258400f1cc4 (diff) | |
download | libbsd-acb577d6c150370ea17fe5a07bd1361bfa4d18e2.tar.gz |
Sync humanize_number from NetBSD
Add the missing man page.
Diffstat (limited to 'src')
-rw-r--r-- | src/humanize_number.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/humanize_number.c b/src/humanize_number.c index fe2f45e..f8cf633 100644 --- a/src/humanize_number.c +++ b/src/humanize_number.c @@ -1,4 +1,4 @@ -/* $NetBSD: humanize_number.c,v 1.11 2006/06/08 21:08:56 simonb Exp $ */ +/* $NetBSD: humanize_number.c,v 1.14 2008/04/28 20:22:59 martin Exp $ */ /* * Copyright (c) 1997, 1998, 1999, 2002 The NetBSD Foundation, Inc. @@ -109,7 +109,12 @@ humanize_number(char *buf, size_t len, int64_t bytes, for (max = 100, i = len - baselen; i-- > 0;) max *= 10; - for (i = 0; bytes >= max && i < maxscale; i++) + /* + * Divide the number until it fits the given column. + * If there will be an overflow by the rounding below, + * divide once more. + */ + for (i = 0; bytes >= max - 50 && i < maxscale; i++) bytes /= divisor; if (scale & HN_GETSCALE) |