fmt_human(3)
π fmt_human(3) π
okay bestie, welcome to the Library Functions Manual, section 3, where we talk about fmt_human β she's a little function with big main character energy, and yes, she lives in the library functions girlies. let's get into it π«Ά
β¨ NAME β¨
fmt_human β writes a human readable ASCII representation of a long integer. literally her whole job. iconic of her tbh π
πΈ SYNTAX πΈ
#include <libowfat/fmt.h>
size_t fmt_human(char *dest,unsigned long long source);
copy it exactly, no notes, she's perfect as is π
π¦ DESCRIPTION π¦
so basically, fmt_human takes your source (a long integer, but make it cute) and writes a human readable ASCII representation of it into dest. then she tells you how many bytes she wrote, by returning that number. no cap.
the result is giving major "file size output of ls -H" vibes. like:
1000becomes"1.0k"β¨1000000becomes"1.0M"β¨- and so on and so on for
"G"and"T"π
one thing to know, and this is important, bestie: fmt_human does not append \0. she's not gonna null-terminate that string for you. she said figure it out π
now, if dest equals FMT_LEN (i.e. it is zero), then fmt_human won't write anything β instead she just returns the number of bytes she would have written. so you can ask her "hey how big would this be" and she'll tell you, no actual writing required. queen behaviour fr fr π
also, heads up: the output of fmt_human can not exceed 11 bytes (that's assuming unsigned long long has 64 bits). so don't come for her with a buffer smaller than that, mwah π
π₯ SEE ALSO π₯
fmt_humank(3)scan_human(3)
go read those too, they're her besties, the friend group is immaculate π
sign-off time, babe π this little love letter came from the Library Functions Manual and it's all about fmt_human(3). that's the whole page, you ate it up, mwah πβ¨
π¦ where this page comes from
- alpine 3.24: libowfat-doc 0.34-r0 Β· GPL-2.0-only
- debian bookworm: libowfat-dev 0.32-4 Β· GPL-2.0-only
- debian trixie: libowfat-dev 0.32-5 Β· GPL-2.0-only
- nixos 26.05: libowfat 0.34
- nixpkgs unstable: libowfat 0.34
- opensuse-leap 16.0: libowfat-devel 0.33-bp160.1.11 Β· GPL-2.0-only
- opensuse-leap 16.0: libowfat-devel 0.33-bp160.1.11 Β· GPL-2.0-only
- opensuse-leap 16.0: libowfat-devel 0.33-bp160.1.11 Β· GPL-2.0-only
- opensuse-leap 16.0: libowfat-devel 0.33-bp160.1.11 Β· GPL-2.0-only
- ubuntu noble: libowfat-dev 0.32-4.1build1 Β· GPL-2.0-only
- ubuntu questing: libowfat-dev 0.32-5
- ubuntu resolute: libowfat-dev 0.34-2 Β· GPL-2.0-only
- ubuntu stonking: libowfat-dev 0.34-2 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms