@@ -1260,25 +1260,27 @@ extern SDL_DECLSPEC int SDLCALL SDL_asprintf(char **strp, SDL_PRINTF_FORMAT_STRI
12601260extern SDL_DECLSPEC int SDLCALL SDL_vasprintf (char **strp, SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap) SDL_PRINTF_VARARG_FUNCV(2 );
12611261
12621262/* *
1263- * Seed the pseudo-random number generator.
1263+ * Seeds the pseudo-random number generator.
12641264 *
1265- * Reusing the seed number will cause SDL_rand () to repeat the same stream of
1266- * 'random' numbers.
1265+ * Reusing the seed number will cause SDL_rand_* () to repeat the same stream
1266+ * of 'random' numbers.
12671267 *
12681268 * \param seed the value to use as a random number seed, or 0 to use
12691269 * SDL_GetPerformanceCounter().
12701270 *
12711271 * \threadsafety This should be called on the same thread that calls
1272- * SDL_rand()
1272+ * SDL_rand* ()
12731273 *
12741274 * \since This function is available since SDL 3.0.0.
12751275 *
1276- * \sa SDL_rand
1276+ * \sa SDL_rand_n
1277+ * \sa SDL_rand_float
1278+ * \sa SDL_rand_bits
12771279 */
12781280extern SDL_DECLSPEC void SDLCALL SDL_srand (Uint64 seed);
12791281
12801282/* *
1281- * Get 32 pseudo-random bits.
1283+ * Generates 32 pseudo-random bits.
12821284 *
12831285 * You likely want to use SDL_rand_n() to get a psuedo-randum number instead.
12841286 *
@@ -1301,38 +1303,44 @@ extern SDL_DECLSPEC void SDLCALL SDL_srand(Uint64 seed);
13011303 * \sa SDL_rand_n
13021304 * \sa SDL_rand_float
13031305 */
1304- extern SDL_DECLSPEC Uint32 SDLCALL SDL_rand (void );
1306+ extern SDL_DECLSPEC Uint32 SDLCALL SDL_rand_bits (void );
13051307
13061308/* *
1307- * Generates a pseudo-random number less than n
1309+ * Generates a pseudo-random number less than n for positive n
13081310 *
1309- * The method used is faster and of better quality than `SDL_rand () % n`.
1310- * However just like with `SDL_rand() % n`, bias increases with larger n. Odds
1311- * are better than 99.9% even for n under 1 million .
1311+ * The method used is faster and of better quality than `rand () % n`.
1312+ * Odds are roughly 99.9% even for n = 1 million. Evenness is better for
1313+ * smaller n, and much worse as n gets bigger .
13121314 *
13131315 * Example: to simulate a d6 use `SDL_rand_n(6) + 1` The +1 converts 0..5 to
13141316 * 1..6
13151317 *
1318+ * If you want reproducible output, be sure to initialize with SDL_srand() first.
1319+ *
13161320 * There are no guarantees as to the quality of the random sequence produced,
13171321 * and this should not be used for security (cryptography, passwords) or where
13181322 * money is on the line (loot-boxes, casinos). There are many random number
13191323 * libraries available with different characteristics and you should pick one
13201324 * of those to meet any serious needs.
13211325 *
1322- * \param n the number of possible values.
1323- * \returns a random value in the range of [0 .. n-1].
1326+ * \param n the number of possible outcomes. n must be positive.
1327+ *
1328+ * \returns a random value in the range of [0 .. n-1]
13241329 *
13251330 * \threadsafety All calls should be made from a single thread
13261331 *
13271332 * \since This function is available since SDL 3.0.0.
13281333 *
1329- * \sa SDL_rand
1334+ * \sa SDL_srand
1335+ * \sa SDL_rand_float
13301336 */
1331- extern SDL_DECLSPEC Uint32 SDLCALL SDL_rand_n (Uint32 n);
1337+ extern SDL_DECLSPEC Sint32 SDLCALL SDL_rand_n (Sint32 n);
13321338
13331339/* *
13341340 * Generates a uniform pseudo-random floating point number less than 1.0
13351341 *
1342+ * If you want reproducible output, be sure to initialize with SDL_srand() first.
1343+ *
13361344 * There are no guarantees as to the quality of the random sequence produced,
13371345 * and this should not be used for security (cryptography, passwords) or where
13381346 * money is on the line (loot-boxes, casinos). There are many random number
@@ -1345,7 +1353,8 @@ extern SDL_DECLSPEC Uint32 SDLCALL SDL_rand_n(Uint32 n);
13451353 *
13461354 * \since This function is available since SDL 3.0.0.
13471355 *
1348- * \sa SDL_rand
1356+ * \sa SDL_srand
1357+ * \sa SDL_rand_n
13491358 */
13501359extern SDL_DECLSPEC float SDLCALL SDL_rand_float (void );
13511360
0 commit comments