History log of /freebsd-10-stable/lib/libutil/humanize_number.3
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 335891 03-Jul-2018 robak

MFC r327317:

humanize_number(3): fix math edge case in rounding large numbers

Fix for remainder overflow, when in rare cases adding remainder to divider
exceeded 1 and turned the total to 1000 in final formatting, taking up
the space for the unit character.

The fix continues the division of the original number if the above case
happens -- added the appropriate check to the for loop performing
the division. This lowers the value shown, to make it fit into the buffer
space provided (1.0M for 4+1 character buffer, as used by ls).

Add test case for the reported bug and extend test program to support
providing buffer length (ls -lh uses 5, tests hard-coded 4).

PR: 224498


# 256281 10-Oct-2013 gjb

Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation

# 256130 07-Oct-2013 jmg

don't assert on bad args, instead return an error..

Since so many programs don't check return value, always NUL terminate
the buf...

fix rounding when using base 1024 (the bug that started it all)...

add a set of test cases so we can make sure that things don't break
in the future...

Thanks to Clifton Royston for testing and the test program...

Approved by: re (hrs, glebius)
MFC after: 1 week


# 220582 12-Apr-2011 delphij

Add support for IEE/IEC (and now also SI) power of two notions of
prefixes (Ki, Mi, Gi...) for humanize_number(3).

Note that applications has to pass HN_IEC_PREFIXES to use this
feature for backward compatibility reasons.

Reviewed by: arundel
MFC after: 2 weeks


# 219850 21-Mar-2011 gjb

s/buffer/buf as is used in the code.

Submitted by: arundel (via doc@)
MFC after: 3 days


# 204587 02-Mar-2010 joel

The NetBSD Foundation has granted permission to remove clause 3 and 4 from
their software.

Obtained from: NetBSD


# 172381 28-Sep-2007 obrien

Adjust history.

Approved by: re(ken)


# 172048 05-Sep-2007 pjd

Point expand_number(3) at humanize_number(3) and nive versa.

Suggested by: trhodes
Approved by: re (kensmith)


# 162385 17-Sep-2006 ru

Markup fixes.


# 160389 15-Jul-2006 imp

Note the convention that humanize_number follows.
Add 'engineering' numbers to table.


# 144863 10-Apr-2005 delphij

Remove duplicated "bytes".

Submitted by: Wojciech A. Koszek [dunstan freebsd czest pl]
PR: 79747


# 135820 26-Sep-2004 pjd

Backout manual page updates.

Requested by: ru


# 135792 25-Sep-2004 pjd

Take the lastest fixes from NetBSD.

Obtained from: NetBSD


# 135317 16-Sep-2004 pjd

There is no such manual page in FreeBSD.


# 131759 07-Jul-2004 ru

Markup fixes.


# 129733 25-May-2004 pjd

Humanize_number(3) is a part of libutil.


# 129730 25-May-2004 trhodes

You want to include libutil.h, not util.h.
Some minor sentence tweaking.


# 129677 24-May-2004 pjd

Add humanize_number(3) to libutil for formating numbers into a human
readable form.

Obtained from: NetBSD