SDL_rand_bits_r(3)
π NAME π
SDL_rand_bits_r β generate 32 pseudo-random bits. That's the whole gig bestie, she's a one-job icon β¨
π¦ SYNOPSIS π¦
#include <SDL3/SDL_stdinc.h>
Uint32 SDL_rand_bits_r(Uint64 *state);
β¨ DESCRIPTION β¨
Okay so real talk: you probably don't want this one. Like, you almost certainly want SDL_rand_r() to get an actual pseudo-random number instead. This is the low-level bit-shuffler, the one the cooler functions are built on. iykyk π
And now the part where I have to be the responsible friend: there are no guarantees about the quality of the random sequence produced. None. Zero. Nada. So do not use this for security stuff (cryptography, passwords) and do not use it anywhere money is on the line (loot-boxes, casinos) π β imagine losing the gacha because your RNG was vibes-based, absolutely not.
There are many random number libraries out there, each with different characteristics, and if you have serious needs you should go pick one of those. This one is for fun little non-serious randomness, periodt. π
π FUNCTION PARAMETERS π
stateβ a pointer to the current random number state. This may not beNULL. Not even a little. Not even for a second. π
π RETURN VALUE π
It hands you back a random value in the range of [0-SDL_MAX_UINT32]. Slay. π«Ά
π₯ THREAD SAFETY π₯
This function is thread-safe β as long as the state pointer isn't being shared between threads. Share the state, share the chaos, and that's on you bestie π
π AVAILABILITY π
This function has been available since SDL 3.2.0. So if you're on anything older, no bits for you π¦
π SEE ALSO π
Simple Directmedia Layer Β· SDL 3.4.18 β that's the source and the version, and this little love letter to SDL_rand_bits_r(3) is officially a wrap. go forth and randomize responsibly, bestie πΈππ
π¦ where this page comes from
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms