expand\_number(3bsd) 3bsd expand\_number(3bsd)

# [NAME](#NAME)

`expand_number` — format a number from human readable form

# [LIBRARY](#LIBRARY)

library “libbsd”

# [SYNOPSIS](#SYNOPSIS)

`#include <libutil.h>` (See [libbsd(7)](/man/os/libbsd/libbsd.7) for include usage.)  
`int`  
`expand_number`(`const char *buf`, `uint64_t *num`);

# [DESCRIPTION](#DESCRIPTION)

The [`expand_number`](#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`](#expand_number~2)() function follows the SI power of two convention.

The prefixes are:

[**Prefix**](#Prefix) [**Description**](#Description) [**Multiplier**](#Multiplier) [`k`](#k) [kilo](#kilo) 1024 [`M`](#M) [mega](#mega) 1048576 [`G`](#G) [giga](#giga) 1073741824 [`T`](#T) [tera](#tera) 1099511627776 [`P`](#P) [peta](#peta) 1125899906842624 [`E`](#E) [exa](#exa) 1152921504606846976

# [RETURN VALUES](#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](#ERRORS)

The `expand_number`() function will fail if:

\[[`EINVAL`](#EINVAL)]

The given string contains no digits.

\[[`EINVAL`](#EINVAL~2)]

An unrecognized prefix was given.

\[[`ERANGE`](#ERANGE)]

Result doesn't fit into 64 bits.

# [SEE ALSO](#SEE_ALSO)

[humanize\_number(3bsd)](/man/os/libbsd/humanize_number.3bsd)

# [HISTORY](#HISTORY)

The `expand_number`() function first appeared in FreeBSD 6.3.

August 15, 2010 Linux 4.19.0-gvisor

---

Document: expand_number(3bsd) from libbsd 0.12.2-r9 (Chainguard OS)
Source: https://gitlab.freedesktop.org/libbsd/libbsd
