format a number into a human readable form and vice
() function formats the
signed 64 bit quantity given in number
. A space and then the
(if not null) is appended to the end.
gives the size of the
If the formatted number (including suffix
would be too long to fit into buffer
repeatedly divide number
by 1024 until it
will fit. In this case, prefix suffix
the appropriate SI designator.
The prefixes are:
must be at least 4 plus the length of
, in order to ensure a useful result is
generated into buffer
. To use a specific
prefix, specify this as scale
1024 ^ scale). The scale
must be at least 0
and no more than 6.
Alternatively, one of the following special values may be given as
- Format the buffer using the lowest multiplier possible.
- Return the prefix index number (the number of times
number must be divided to fit) instead of
formatting it to the buffer. That is, the
scale that would have been used if
HN_AUTOSCALE had been used.
The following flags may be passed in flags
- If the final numeric result is less than 10, and is not the same as the
original value (that is, it has been scaled) display it using a decimal
radix character, and one following digit.
- Do not put a space between number and the
- Use 'B' (bytes) as prefix if the original result does not have a
- Divide number with 1000 instead of 1024.
That is, use decimal scaling instead of binary.
To generate the shortest meaningful value, a buffer length
) that is 6 greater the length of the
will ensure the highest
meaningful scale is used. Allow one extra byte for the sign if the number is
negative, and one less if the
flag is used.
() function parses the
string representing an integral value given in
and stores the numerical value in the
integer pointed to by result
. The provided
string may hold one of the suffixes, which will be interpreted and used to
scale up its accompanying numerical value.
() returns the number of
characters stored in buffer
terminating NUL) upon success, or -1 upon failure. If
is specified, the prefix index
number will be returned instead.
() returns 0 if the string
was parsed correctly. A -1 is returned to indicate failure and an error code
is stored in errno
() will fail and no number
will be stored in result
- The string in str was empty or carried an
- The string in str represented a number
that does not fit in result.
() first appeared in
() first appeared in