---
name: "expand_number"
section: "3bsd"
platform: "linux"
package: "libbsd"
version: "0.12.2-2"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/expand_number/3bsd"
---

# expand\_number(3bsd)

format a number from human readable form

## NAME

**expand\_number** – format a number from human readable form

## LIBRARY

library “libbsd”

## SYNOPSIS

**#include \<libutil.h\>**

(See [libbsd(7)](/libbsd/7.md) for include usage.)

*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:

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

## 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(3bsd)](/humanize_number/3bsd.md)

## HISTORY

The **expand\_number**() function first appeared in FreeBSD 6.3.
