1expand_number(3bsd) LOCAL expand_number(3bsd)
2
4 expand_number — format a number from human readable form
5
7 Utility functions from BSD systems (libbsd, -lbsd)
8
10 #include <libutil.h>
11 (See libbsd(7) for include usage.)
12
13 int
14 expand_number(const char *buf, uint64_t *num);
15
17 The expand_number() function unformats the buf string and stores a un‐
18 signed 64-bit quantity at address pointed out by the num argument.
19
20 The expand_number() function follows the SI power of two convention.
21
22 The prefixes are:
23
24 Prefix Description Multiplier
25 k kilo 1024
26 M mega 1048576
27 G giga 1073741824
28 T tera 1099511627776
29 P peta 1125899906842624
30 E exa 1152921504606846976
31
33 Upon successful completion, the value 0 is returned; otherwise the
34 value -1 is returned and the global variable errno is set to indicate the
35 error.
36
38 The expand_number() function will fail if:
39
40 [EINVAL] The given string contains no digits.
41
42 [EINVAL] An unrecognized prefix was given.
43
44 [ERANGE] Result doesn't fit into 64 bits.
45
47 humanize_number(3bsd)
48
50 The expand_number() function first appeared in FreeBSD 6.3.
51
52BSD August 15, 2010 BSD