fmt_humank(3)

πŸ“¦
version 0.34 Β· 2 versions
  • 0.34 Β· alpine 3.24, debian bookworm, debian trixie, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking (latest)
  • 0.30 Β· fedora 43, fedora 44, ubuntu jammy
, in alpine 3.24, debian bookworm, debian trixie, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ fmt_humank ✨

okay bestie, sit down, hydrate, because this one is adorable and you're gonna use it literally every day πŸ’–


πŸŽ€ NAME πŸŽ€

fmt_humank β€” write a human readable ASCII representation of a long integer


πŸ¦‹ SYNTAX πŸ¦‹

#include <libowfat/fmt.h>

size_t fmt_humank(char *dest,unsigned long long source);

🌸 DESCRIPTION 🌸

so here's the vibe: fmt_humank writes a human readable ASCII representation of source to dest, and then it hands you back the number of bytes it wrote. that's the whole thing. she's simple, she's elegant, she ate πŸ’…

the result looks like the file size output of ls -h, no cap:

  • 1024 becomes "1.0k"
  • 1048576 becomes "1.0M"
  • and so on for "G" and "T" πŸ”₯

one thing to know: fmt_humank does not append \0. nope. not even a little. it writes the digits and dips, so if you need a null terminator that's a you problem, bestie 😭

and if dest equals FMT_LEN (i.e. is zero), then fmt_humank returns the number of bytes it would have written. it's giving "window shopping" energy β€” you get the size without the actual output πŸ™ˆ

also, the output of fmt_humank can not exceed 11 (assuming unsigned long long has 64 bits). so budget for that and you're golden πŸ‘‘

πŸ‘‘ SEE ALSO πŸ‘‘


and that's the whole page, fr fr 🫢 this little icon lives in the Library Functions Manual and she's fmt_humank(3) through and through β€” go format something pretty with her πŸŒˆβœ¨πŸŽ€