Skip to content

Commit 86b06f7

Browse files
JKaniarzslouken
authored andcommitted
Updated docs
1 parent 3ee4bff commit 86b06f7

File tree

1 file changed

+30
-16
lines changed

1 file changed

+30
-16
lines changed

include/SDL3/SDL_stdinc.h

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,7 +1260,10 @@ extern SDL_DECLSPEC int SDLCALL SDL_asprintf(char **strp, SDL_PRINTF_FORMAT_STRI
12601260
extern 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+
* Seed the pseudo-random number generator.
1264+
*
1265+
* Reusing the seed number will cause SDL_rand() to repeat the same stream
1266+
* of 'random' numbers.
12641267
*
12651268
* \param seed the value to use as a random number seed, or 0 to use
12661269
* SDL_GetPerformanceCounter().
@@ -1275,13 +1278,17 @@ extern SDL_DECLSPEC int SDLCALL SDL_vasprintf(char **strp, SDL_PRINTF_FORMAT_STR
12751278
extern SDL_DECLSPEC void SDLCALL SDL_srand(Uint64 seed);
12761279

12771280
/**
1278-
* Get a pseudo-random number.
1281+
* Get 32 pseudo-random bits.
1282+
*
1283+
* You likely want to use SDL_rand_n() to get a psuedo-randum number instead.
1284+
*
1285+
* If you want reproducible output, be sure to initialize with SDL_srand() first.
12791286
*
12801287
* There are no guarantees as to the quality of the random sequence produced,
1281-
* and this should not be used for cryptography or anything that requires good
1282-
* random distribution. There are many random number libraries available with
1283-
* different characteristics and you should pick one of those to meet any
1284-
* serious needs.
1288+
* and this should not be used for security (cryptography, passwords) or where
1289+
* money is on the line (loot-boxes, casinos). There are many random number
1290+
* libraries available with different characteristics and you should pick one of
1291+
* those to meet any serious needs.
12851292
*
12861293
* \returns a random value in the range of [0-SDL_MAX_UINT32].
12871294
*
@@ -1292,17 +1299,19 @@ extern SDL_DECLSPEC void SDLCALL SDL_srand(Uint64 seed);
12921299
*
12931300
* \sa SDL_rand_r
12941301
* \sa SDL_srand
1302+
* \sa SDL_rand_n
1303+
* \sa SDL_rand_float
12951304
*/
12961305
extern SDL_DECLSPEC Uint32 SDLCALL SDL_rand(void);
12971306

12981307
/**
1299-
* Get a pseudo-random number.
1308+
* Get 32 pseudo-random bits.
13001309
*
13011310
* There are no guarantees as to the quality of the random sequence produced,
1302-
* and this should not be used for cryptography or anything that requires good
1303-
* random distribution. There are many random number libraries available with
1304-
* different characteristics and you should pick one of those to meet any
1305-
* serious needs.
1311+
* and this should not be used for security (cryptography, passwords) or where
1312+
* money is on the line (loot-boxes, casinos). There are many random number
1313+
* libraries available with different characteristics and you should pick one of
1314+
* those to meet any serious needs.
13061315
*
13071316
* \param state a pointer to a 64-bit seed value that will be updated with
13081317
* each call to SDL_rand_r(). If the value of the seed is 0, it
@@ -1324,13 +1333,16 @@ extern SDL_DECLSPEC Uint32 SDLCALL SDL_rand_r(Uint64 *state);
13241333
*
13251334
* The method used is faster and of better quality than `SDL_rand() % n`.
13261335
* However just like with `SDL_rand() % n`, bias increases with larger n.
1336+
* Odds are better than 99.9% even for n under 1 million.
13271337
*
13281338
* Example: to simulate a d6 use `SDL_rand_n(6) + 1`
13291339
* The +1 converts 0..5 to 1..6
13301340
*
13311341
* There are no guarantees as to the quality of the random sequence produced,
1332-
* and this should not be used for cryptography or anything that requires good
1333-
* random distribution.
1342+
* and this should not be used for security (cryptography, passwords) or where
1343+
* money is on the line (loot-boxes, casinos). There are many random number
1344+
* libraries available with different characteristics and you should pick one of
1345+
* those to meet any serious needs.
13341346
*
13351347
* \param n the number of possible values
13361348
*
@@ -1345,11 +1357,13 @@ extern SDL_DECLSPEC Uint32 SDLCALL SDL_rand_r(Uint64 *state);
13451357
extern SDL_DECLSPEC Uint32 SDLCALL SDL_rand_n(Uint32 n);
13461358

13471359
/**
1348-
* Generates a pseudo-random floating point number less than 1.0
1360+
* Generates a uniform pseudo-random floating point number less than 1.0
13491361
*
13501362
* There are no guarantees as to the quality of the random sequence produced,
1351-
* and this should not be used for cryptography or anything that requires good
1352-
* random distribution.
1363+
* and this should not be used for security (cryptography, passwords) or where
1364+
* money is on the line (loot-boxes, casinos). There are many random number
1365+
* libraries available with different characteristics and you should pick one of
1366+
* those to meet any serious needs.
13531367
*
13541368
* \returns a random value in the range of [0.0, 1.0)
13551369
*

0 commit comments

Comments
 (0)