atof(3)
โจ atof(3) โจ
okay bestie, gather round, we're talking about atof โ the lil libc function that turns your string into a double. she's in section 3 of the manual (library functions, iykyk) and she is so simple it's almost suspicious. let's get into it ๐
๐ธ NAME ๐ธ
atof โ convert a string to a double
like. that's it. that's her whole job. she takes text and gives you a floaty number back. iconic ๐
๐ LIBRARY ๐
Standard C library โ you already have her, she lives in libc, link with -lc ๐ซถ
๐ SYNOPSIS ๐
#include <stdlib.h>
double atof(const char *nptr);
yes bestie, just <stdlib.h> and a pointer to some chars. nothing else. she's low maintenance. periodt โจ
๐ซ DESCRIPTION ๐ซ
So the atof() function converts the initial portion of the string pointed to by nptr into a double. not the whole string necessarily โ the initial portion, okay? she reads what she can, she does her thing.
And the behavior? It's literally the same as:
strtod(nptr, NULL);
like, copy paste, same energy. BUT โ and this is the part where you go ๐ญ โ there's one big exception: atof() does not detect errors. none. zero. she does not check. she does not warn you. she just vibes and returns whatever. so if you fed her chaos, she's giving you chaos right back and you will simply not know about it. no cap, that's a real trap.
๐ RETURN VALUE ๐
The converted value. that's the whole description. she gives you the number. that's it. ๐
๐ฆ ATTRIBUTES ๐ฆ
okay so for the terms used in this section, go check out attributes(7) if you want the full lore. here's the tea for atof():
- Interface:
atof()- Attribute: Thread safety
- Value:
MT-Safe locale
so she's MT-Safe but locale-dependent. keep that in mind ๐
โญ STANDARDS โญ
C11, POSIX.1-2008. she's certified, she's legit, she's in the standards ๐
๐ HISTORY ๐
POSIX.1-2001, C89, C99, SVr4, 4.3BSD. she's been around forever. vintage queen. not a new girl, an established girl ๐
๐ SEE ALSO ๐
go read her friends, they're all family fr fr:
quick reminder bestie: if you actually care about knowing whether the conversion worked,atof()is not the one. she won't tell you. go talk tostrtod(3)instead, she'll give you the receipts. ๐ซถ
mwah that's the page! this was pulled straight from Linux man-pages 6.20, dated 2026-02-08, and yes she's still atof(3). stay slay, validate your inputs, and don't let a silent error ruin your day ๐โจ๐๐ฆ๐ธ
๐ฆ where this page comes from
- arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- ๐ the page's license: Linux-man-pages-copyleft
- Copyright 1993, David Metcalfe <david@prism.demon.co.uk>
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms