SDL_modf(3)

✨ SDL_modf ✨

okay bestie, welcome to the SDL_modf(3) page from the SDL3 FUNCTIONS collection πŸ’– this one is short, sweet, and honestly kind of iconic β€” it splits a number in two like it's dividing the aux cord between you and your bestie πŸŽ€


🌸 NAME 🌸

SDL_modf β€” split x into integer and fractional parts. it's giving "cut the pizza, keep both slices" πŸ“


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <SDL3/SDL_stdinc.h>

double SDL_modf(double x, double *y);

like. one include. one function call. that's it. no cap ✨


πŸ’… DESCRIPTION πŸ’…

okay so here's the tea: this function operates on double-precision floating point values πŸ’œ so if you're rolling with doubles, you're in the right place.

but if you're a float girlie (single-precision), you do NOT belong here β€” you want SDL_modff instead. don't mix them up, i'm literally begging πŸ™ˆ


🌈 FUNCTION PARAMETERS 🌈

  • x β€” floating point value. the number that's about to get split, main character energy fr πŸ’«
  • y β€” output pointer to store the integer part of x. bestie this is a pointer, so hand it an address, not a value πŸ‘‘

⭐ RETURN VALUE ⭐

Returns the fractional part of x πŸŽ€

so like, x goes in, and the function hands you back the fractional half while dropping the integer half into wherever *y points. teamwork. iconic. periodt πŸ’…


🧚 THREAD SAFETY 🧚

It is safe to call this function from any thread 🫢 no locks, no drama, no situationship with your mutex. call it from literally anywhere. slay πŸ”₯


πŸ‘‘ AVAILABILITY πŸ‘‘

This function is available since SDL 3.2.0 ⭐ so if you're on anything older... yeah. update bestie, it's 3.2.0+, no excuses 🌸


πŸ’– SEE ALSO πŸ’–

iykyk β€” go read those next, they're all part of the same friend group 🌈


lowkey reminder: y is a pointer and it's an output parameter, so make sure it points somewhere real before you call this. undefined behaviour is not the vibe, bestie πŸ’€

kisses, this page was served up by Simple Directmedia Layer, version SDL 3.4.18 πŸ’–βœ¨πŸŽ€ go forth and split those doubles, you absolute legend πŸ¦‹πŸ‘‘

πŸ“¦ where this page comes from