fmt_double(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

okay bestie, grab your iced coffee because we're diving into fmt_double(3) from the Library Functions Manual. she's a whole vibe and she's about to write some doubles for you. no cap. πŸ’…

πŸŽ€ NAME πŸŽ€

fmt_double β€” she writes an ASCII representation of a double. that's it. that's the tweet. literally her entire purpose. periodt. πŸ’–

✨ SYNTAX ✨

first things first, you gotta include the header, bestie:

#include <libowfat/fmt.h>

and here's the function signature, copy it exactly or she will not answer:

size_t fmt_double(char *dest,double d,size_t maxlen,size_t prec);

πŸ’… DESCRIPTION πŸ’…

okay so boom. fmt_double writes an ASCII representation of d β€” and when I say ASCII, I mean '0' through '9', base 10, none of that hexadecimal nonsense β€” directly into dest. then she returns the number of bytes she actually wrote. so far so good? 🫢

but wait, there's a limit. she will not write more than maxlen bytes. that's the rule. don't try to make her write more, she won't. 🚫

and she's precise, okay? she writes exactly prec digits. and if she has to, she'll use scientific notation. because sometimes that's just the mood. ✨

bestie, listen. fmt_double does not append a \0. if you were expecting a null-terminated string, I'm so sorry, she's not that girl. you have to handle that yourself. 😭

one more thing β€” if dest equals FMT_LEN (i.e. it's zero), she doesn't write anything at all. instead she just tells you how many bytes she would have written. it's giving "window shopping". iconic. πŸ‘‘

πŸ” SEE ALSO πŸ”


mwah πŸ’– this has been your bestie from the Library Functions Manual, fmt_double(3), signing off. stay precise, stay slay. ✨