tail head cat sleep
QR code linking to this page

Manual Pages  — EXPAND_NUMBER

NAME

expand_number – format a number from human readable form

CONTENTS

LIBRARY

System Utilities Library (libutil, -lutil)

SYNOPSIS

#include <libutil.h>

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

DESCRIPTION

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:
Suffix Description Multiplier
K kilo 1024
M mega 1048576
G giga 1073741824
T tera 1099511627776
P peta 1125899906842624
E exa 1152921504606846976

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.

RETURN VALUES

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.

ERRORS

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.

SEE ALSO

humanize_number(3)

HISTORY

The expand_number() function first appeared in FreeBSD 6.3 .

EXPAND_NUMBER (3) June 13, 2023

tail head cat sleep
QR code linking to this page


Please direct any comments about this manual page service to Ben Bullock. Privacy policy.

As soon as we started programming, we found to our surprise that it wasn't as easy to get programs right as we had thought. Debugging had to be discovered. I can remember the exact instant when I realized that a large part of my life from then on was going to be spent in finding mistakes in my own programs.
— Maurice Wilkes