Date: Tue, 12 Feb 2002 06:00:04 -0800 (PST) From: Tomas Svensson <tsn@gbdev.net> To: freebsd-bugs@FreeBSD.org Subject: Re: bin/34834: "fix" of du(1) and -h Message-ID: <200202121400.g1CE04u11713@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/34834; it has been noted by GNATS.
From: Tomas Svensson <tsn@gbdev.net>
To: "Crist J. Clark" <cjc@FreeBSD.ORG>
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: bin/34834: "fix" of du(1) and -h
Date: Tue, 12 Feb 2002 14:52:46 +0100
Tuesday, February 12, 2002, 12:50:37 PM, you wrote:
CJC> On Mon, Feb 11, 2002 at 10:36:46AM -0500, Tomas Svensson wrote:
CJC> [snip]
>> >Description:
>> The manpages for df(1), du(1) and ls(1) claim that -h (print human-
>> readable numbers) will reduce the number of digits to three or fewer,
>> but this isn't true. It will print numbers such as 1000K or 1010K
>> (since these are slightly less than a megabyte). Also, the 'K' for
>> kilo should really be 'k'.
CJC> 'k' is generally used for multiples of 1000. 'K' is used for multiples
CJC> of 1024. Sticking with 'K' is prefered except possibly for the '-H'
CJC> option of df(1). But it seems like a lot of trouble to change that one
CJC> case to 'k'.
Yes you're right, change the 'k' to 'K'. Just because 3-4 people told
me that 'k' was right, I assumed that they were correct.
CJC> The current method does seem to be overkill. Why not just divide by
CJC> 1024 n-times until the result is < 1024 rather than ilogb(3)? We lose
CJC> the math library, and we don't need that table of values.
< 1024 will still give the irritating '1000K' result.
CJC> One comment about the patch,
CJC> [snip]
>> + printf("%qd.%qd%c", s1, s2, prefixes[i]);
>> + } else
>> + printf("%3qd%c", (bytes + 50) / 100, prefixes[i]);
CJC> Quads? Ewwww...
The smaller types won't do for the calculation, so no point in
convertning before printing? (Ok, s1 and s2 doesn't need to be quads).
-Tomas
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200202121400.g1CE04u11713>
