expand_number (3) - Linux Manuals

expand_number: format a number from human readable form

NAME

expand_number - format a number from human readable form

LIBRARY

Lb libbsd

SYNOPSIS

In bsd/libutil.h Ft int Fo expand_number Fa const char *buf uint64_t *num Fc

DESCRIPTION

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

The Fn expand_number function follows the SI power of two convention.

The prefixes are:

Prefix Ta Description Ta Multiplier
k Ta kilo Ta 1024
M Ta mega Ta 1048576
G Ta giga Ta 1073741824
T Ta tera Ta 1099511627776
P Ta peta Ta 1125899906842624
E Ta exa Ta 1152921504606846976

RETURN VALUES

Rv -std

ERRORS

The Fn expand_number function will fail if:

Bq Er EINVAL
The given string contains no digits.
Bq Er EINVAL
An unrecognized prefix was given.
Bq Er ERANGE
Result doesn't fit into 64 bits.

HISTORY

The Fn expand_number function first appeared in Fx 6.3 .

SEE ALSO

humanize_number3