EXPAND_NUMBER(3)

πŸ“¦
version 73 Β· 3 versions
, in nixpkgs unstable

πŸ’… EXPAND_NUMBER(3) β€” the libutil glow-up

okay bestie, so this is a page from the Library Functions Manual, and the function at the center of it all is expand_number β€” she takes a cute little human-readable string and turns it into a real actual number. main character energy fr fr.


✨ NAME ✨

expand_number β€” format a number from human readable form πŸŽ€

πŸ“š LIBRARY πŸ“š

System Utilities Library (libutil, -lutil) πŸ’–

🌸 SYNOPSIS 🌸

#include <libutil.h>

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

πŸ’« DESCRIPTION πŸ’«

so the expand_number() function parses the buf string and stores an unsigned 64-bit quantity at *num. that's it, that's the vibe. ✨

expand_number() is case-insensitive (she does not care about your capitalization choices, live your truth) and she follows the SI power of two convention. iykyk.

the suffixes are, and i cannot stress this enough, iconic:

  • K β€” kilo β€” 1024
  • M β€” mega β€” 1048576
  • G β€” giga β€” 1073741824
  • T β€” tera β€” 1099511627776
  • P β€” peta β€” 1125899906842624
  • E β€” exa β€” 1152921504606846976

look at those numbers. enormous. so blessed. πŸ”₯

🫢 RETURN VALUES 🫢

upon successful completion, the value 0 is returned β€” slay πŸ’…

otherwise, the value -1 is returned and the global variable errno is set to indicate the error. not the vibe, but she's honest about it. 😭

πŸ’€ ERRORS πŸ’€

expand_number() will fail if:

  • [EINVAL] β€” the given string contains no digits. literally nothing to work with bestie, where are the numbers πŸ₯²
  • [EINVAL] β€” an unrecognized suffix was given. she does not know her, she does not recognize her 🚫
  • [ERANGE] β€” result doesn't fit into 64 bits. too much woman for this container, the number simply outgrew the format πŸ’€

πŸ‘€ SEE ALSO πŸ‘€

πŸ¦‹ HISTORY πŸ¦‹

the expand_number() function first appeared in FreeBSD 6.3. a humble queen rising. πŸ‘‘


and that's the whole page bestie!! this one came to you from Debian, dated July 20, 2019 β€” periodt, mwah πŸ’‹πŸ’–βœ¨

πŸ“¦ where this page comes from
  • nixpkgs unstable: libutil 73
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms