Reference

expand_number(3)

format a number from human readable form

NAME

expand_number – format a number from human readable form

LIBRARY

library “libbsd”

SYNOPSIS

#include <bsd/libutil.h>

int

expand_number(const char *buf, uint64_t *num);

DESCRIPTION

The expand_number() function unformats the buf string and stores a unsigned 64-bit quantity at address pointed out by the num argument.

The expand_number() function follows the SI power of two convention.

The prefixes are:

PrefixDescriptionMultiplier
kkilo1024
Mmega1048576
Ggiga1073741824
Ttera1099511627776
Ppeta1125899906842624
Eexa1152921504606846976

RETURN VALUES

The expand_number() function returns the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indicate the error.

ERRORS

The expand_number() function will fail if:

[EINVAL]

The given string contains no digits.

[EINVAL]

An unrecognized prefix was given.

[ERANGE]

Result doesn't fit into 64 bits.

SEE ALSO

humanize_number(3)

HISTORY

The expand_number() function first appeared in FreeBSD 6.3.