| Summary: | "fix" of du(1) and -h | ||||||
|---|---|---|---|---|---|---|---|
| Product: | Base System | Reporter: | Tomas Svensson <tsn> | ||||
| Component: | bin | Assignee: | Pawel Jakub Dawidek <pjd> | ||||
| Status: | Closed FIXED | ||||||
| Severity: | Affects Only Me | ||||||
| Priority: | Normal | ||||||
| Version: | 5.0-CURRENT | ||||||
| Hardware: | Any | ||||||
| OS: | Any | ||||||
| Attachments: |
|
||||||
|
Description
Tomas Svensson
2002-02-11 15:40:03 UTC
On Mon, Feb 11, 2002 at 10:36:46AM -0500, Tomas Svensson wrote: [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'. 'k' is generally used for multiples of 1000. 'K' is used for multiples of 1024. Sticking with 'K' is prefered except possibly for the '-H' option of df(1). But it seems like a lot of trouble to change that one case to 'k'. The current method does seem to be overkill. Why not just divide by 1024 n-times until the result is < 1024 rather than ilogb(3)? We lose the math library, and we don't need that table of values. One comment about the patch, [snip] > + printf("%qd.%qd%c", s1, s2, prefixes[i]); > + } else > + printf("%3qd%c", (bytes + 50) / 100, prefixes[i]); Quads? Ewwww... -- Crist J. Clark | cjclark@alum.mit.edu | cjclark@jhu.edu http://people.freebsd.org/~cjc/ | cjc@freebsd.org 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 *ALL* the standard one-letter prefixes strictly denote powers of 10, so being precious over k/K doesn't really help much. See http://physics.nist.gov/cuu/Units/prefixes.html and http://physics.nist.gov/cuu/Units/binary.html for the applicable standards. -- Bob Bishop +44 (0)118 977 4017 rb@gid.co.uk fax +44 (0)118 989 4254 State Changed From-To: open->feedback Could you check if this is fixed in FreeBSD 5.3 or 6-CURRENT? Responsible Changed From-To: freebsd-bugs->pjd Could you check if this is still a problem in 5.3 or 6-CURRENT? State Changed From-To: feedback->closed Submitter e-mail doesn't exist, so I can't get feedback. I think this bug was fixed when humanize_number(3) was introduced. |