SDL_strtod(3)

πŸ’– SDL_strtod(3) πŸ’–

okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual, where today's main character is SDL_strtod β€” she parses a double out of a string and honestly? she's doing it on her own terms. πŸŽ€


✨ NAME ✨

SDL_strtod β€” parse a double from a string. that's it, that's the whole job. πŸ¦‹


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_stdinc.h>

double SDL_strtod(const char *str, char **endp);

πŸ’… DESCRIPTION πŸ’…

so here's the tea, and you're gonna wanna sit down for this one: this function makes fewer guarantees than the C runtime strtod. like, she's the chill lowercase cousin of the big C library one. not me telling you the fine print before you even get attached 😭

  • Only decimal notation is guaranteed to be supported. The handling of scientific and hexadecimal notation is unspecified.
  • Whether or not INF and NAN can be parsed is unspecified.
  • The precision of the result is unspecified.
fr fr, "unspecified" means don't come crying to her if it doesn't do the thing. she never promised. lowkey iconic of her.

🫢 FUNCTION PARAMETERS 🫢

  • str β€” the null-terminated string to read. Must not be NULL. 🚫
  • endp β€” if not NULL, the address of the first invalid character (i.e. the next character after the parsed number) will be written to this pointer. so she tells you exactly where she stopped vibing with your string ✨

⭐ RETURN VALUE ⭐

Returns the parsed double, or 0 if no number could be parsed. zero, queen. slay πŸ’€


🌈 THREAD SAFETY 🌈

It is safe to call this function from any thread. multitasking queen, we love to see it πŸ‘‘


🧚 AVAILABILITY 🧚

This function is available since SDL 3.2.0. so if you're on something older… no she's not there yet, sorry bestie πŸ™ˆ


πŸ”₯ SEE ALSO πŸ”₯

the whole friend group, literally all of them, go say hi πŸ’œ


and that's the page!! brought to you by Simple Directmedia Layer, running SDL 3.4.18 β€” mwah, take care of her, and remember: decimal only unless stated otherwise πŸŽ€βœ¨πŸ’–

πŸ“¦ where this page comes from