SDL_randf_r(3)

✨ SDL_randf_r ✨

okay bestie, so this is a page from the SDL3 FUNCTIONS manual, and today's main character is SDL_randf_r β€” she makes you a uniform pseudo-random floating point number that's less than 1.0. periodt. πŸ’…


🌸 NAME 🌸

SDL_randf_r β€” generate a uniform pseudo-random floating point number less than 1.0 🎲


πŸŽ€ SYNOPSIS πŸŽ€

#include <SDL3/SDL_stdinc.h>

float SDL_randf_r(Uint64 *state);

πŸ¦‹ DESCRIPTION πŸ¦‹

so like, if you want reproducible output, you literally have to initialize with SDL_srand() first. no cap. otherwise she's just doing her own thing. πŸ™ˆ

and now for the vibe check: there are no guarantees as to the quality of the random sequence produced. ngl, this should not be used for security β€” like cryptography, passwords β€” or anywhere money is on the line (loot-boxes, casinos, bestie, think about the casino). there are so many random number libraries out there with all different characteristics, and you should pick one of those to meet any serious needs. this one's just here for the vibes, not the vault. πŸ’€


πŸ’– FUNCTION PARAMETERS πŸ’–

  • state β€” a pointer to the current random number state. and hear me when i say this: this may not be NULL. not even a little. 🫢

⭐ RETURN VALUE ⭐

returns a random value in the range of [0.0, 1.0). slay. ✨


🌈 THREAD SAFETY 🌈

this function is thread-safe β€” as long as the state pointer isn't shared between threads. share the pointer, share the chaos. πŸ‘‘


🧚 AVAILABILITY 🧚

this function is available since SDL 3.2.0. she's been here. 🌸


πŸ’œ SEE ALSO πŸ’œ


and that's the whole page, bestie!! πŸŽ€ this little number lives in the Simple Directmedia Layer manual, version SDL 3.4.18, so if you ever forget where you found her, that's the receipt. bye bye, go make some random floats, ily πŸ’–πŸ¦‹

πŸ“¦ where this page comes from