expand_number
—
format a number from human readable form
System Utilities Library (libutil,
-lutil)
#include
<libutil.h>
int
expand_number
(const char *buf,
uint64_t *num);
The
expand_number
()
function parses the buf string and stores a unsigned
64-bit quantity at *num.
The
expand_number
()
function is case-insensitive and follows the SI power of two convention.
The suffixes are:
For historical reasons, the
expand_number
()
function accepts and ignores a single “B” suffix at the end of
the buf string. However, the usage of this suffix is
discouraged.
Upon successful completion, the value 0 is returned;
otherwise the value -1 is returned and the global variable
errno is set to indicate the error.
The expand_number
() function will fail
if:
- [
EINVAL
]
- The given string contains no digits.
- [
EINVAL
]
- An unrecognized suffix was given.
- [
ERANGE
]
- Result doesn't fit into 64 bits.
The expand_number
() function first
appeared in FreeBSD 6.3.