fmt_xlong(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_xlong(3) β€” a whole vibe from the Library Functions Manual πŸ¦‹

okay bestie sit DOWN because today we're talking about fmt_xlong, and honestly? she's giving quiet-legend energy. no cap. ✨


🌸 NAME 🌸

fmt_xlong β€” write a hexadecimal ASCII representation of an unsigned long integer πŸ’…

like. she takes your big ol' number and turns it into pretty little letters and digits. that's the whole job. iconic.


πŸŽ€ SYNTAX πŸŽ€

lowkey the important part, so pay attention bestie:

#include <libowfat/fmt.h>

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

that's it. two args. no drama. 🫢


✨ DESCRIPTION ✨

so here's the tea, fr fr:

fmt_xlong writes an ASCII representation of source to dest β€” and when we say ASCII representation we mean the characters '0' to '9' and 'a' to 'f', base 16, hexadecimal, the whole shebang. πŸ’œ

and THEN, because she's thoughtful like that, she returns the number of bytes written. so you always know exactly how much she gave you. main character behavior honestly.

⚠️ ok but here's the thing: fmt_xlong does not append \0. not even a little one. she is NOT null-terminating for you. if you need that, that's a you problem, bestie. plan accordingly. 😭

now for the fun part β€” the special case πŸ‘‘

  • If dest equals FMT_LEN (i.e. is zero), fmt_xlong returns the number of bytes it would have written. so she's like "no i'm not writing anything, but here's how long it woulda been" and honestly? respect. πŸ’…

and for convenience β€” because the libowfat girlies love convenience β€” fmt.h defines the integer FMT_XLONG to be big enough to contain every possible fmt_xlong output plus \0. so if you're allocating a buffer, that's your number. use it. love it. don't do math in your head. πŸ“


πŸ‘€ SEE ALSO πŸ‘€

  • scan_xlong(3) β€” the reverse queen, the one who reads it back. iykyk. 🌈

that's the whole page bestie, no filler, no fluff, just fmt_xlong being exactly what she is. go forth and hex. πŸ”₯

this lil gem comes to you straight out of the Library Functions Manual, page fmt_xlong(3) β€” same title in the header, same title in the footer, because symmetry is a serve. no version string, no date, just vibes. πŸ’–βœ¨πŸŒΈπŸ¦‹πŸŽ€πŸ’…πŸ«Ά