SDL_rand_bits(3)

πŸ’– SDL_rand_bits β€” the tea β˜•

okay bestie, so this one's SDL_rand_bits(3), straight out of the SDL3 FUNCTIONS lineup. She's a little function with a big job and honestly? She's serving chaos on purpose. Let's get into it ✨


✨ NAME ✨

SDL_rand_bits β€” she generates 32 pseudo-random bits. that's it. that's the whole gig. πŸ’…


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_stdinc.h>

Uint32 SDL_rand_bits(void);

no arguments, no drama, just vibes and bits πŸ¦‹


πŸ’œ DESCRIPTION πŸ’œ

okay so real talk β€” you probably don't actually want this one. you likely want to use SDL_rand() to get a pseudo-random number instead. like, SDL_rand_bits is the raw ingredient, SDL_rand() is the cute finished meal. choose wisely bestie πŸ“

and now the part where I have to be a responsible bestie and give you the serious face 😭:

there are no guarantees as to the quality of the random sequence produced. none. zero. zip.

so do not use this for security stuff β€” cryptography, passwords, none of that. and do not use it where money is on the line, and yes that means loot-boxes and casinos, I'm looking directly at you πŸ‘€πŸ’€

there are many random number libraries available out there with different characteristics, and you should pick one of those to meet any serious needs. this one is for fun little numbers, not for guarding your diary πŸ”


⭐ RETURN VALUE ⭐

she hands you back a random value in the range of [0-SDL_MAX_UINT32]. inclusive of zero, inclusive of the max, no crumbs left behind πŸ‘‘


🧚 THREAD SAFETY 🧚

all calls should be made from a single thread. don't be out here sharing her across threads, she is not about that life πŸ™ˆ


🌈 AVAILABILITY 🌈

this function has been available since SDL 3.2.0. iconic behavior honestly, she's been here a minute πŸŽ€


πŸ”₯ SEE ALSO πŸ”₯


and that's the whole page bestie, no cap 🫢 this was brought to you by Simple Directmedia Layer, rocking version SDL 3.4.18 β€” go forth and be random, but like, responsibly πŸ’–βœ¨πŸŒΈ

πŸ“¦ where this page comes from