mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-05-30 21:37:43 +08:00
Sync SDL3 wiki -> header
This commit is contained in:
@@ -1262,7 +1262,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_vasprintf(char **strp, SDL_PRINTF_FORMAT_STR
|
|||||||
/**
|
/**
|
||||||
* Seeds the pseudo-random number generator.
|
* Seeds the pseudo-random number generator.
|
||||||
*
|
*
|
||||||
* Reusing the seed number will cause SDL_rand_*() to repeat the same stream
|
* Reusing the seed number will cause SDL_rand_*() to repeat the same stream
|
||||||
* of 'random' numbers.
|
* of 'random' numbers.
|
||||||
*
|
*
|
||||||
* \param seed the value to use as a random number seed, or 0 to use
|
* \param seed the value to use as a random number seed, or 0 to use
|
||||||
@@ -1308,14 +1308,15 @@ extern SDL_DECLSPEC Uint32 SDLCALL SDL_rand_bits(void);
|
|||||||
/**
|
/**
|
||||||
* Generates a pseudo-random number less than n for positive n
|
* Generates a pseudo-random number less than n for positive n
|
||||||
*
|
*
|
||||||
* The method used is faster and of better quality than `rand() % n`.
|
* The method used is faster and of better quality than `rand() % n`. Odds are
|
||||||
* Odds are roughly 99.9% even for n = 1 million. Evenness is better for
|
* roughly 99.9% even for n = 1 million. Evenness is better for smaller n, and
|
||||||
* smaller n, and much worse as n gets bigger.
|
* much worse as n gets bigger.
|
||||||
*
|
*
|
||||||
* Example: to simulate a d6 use `SDL_rand_n(6) + 1` The +1 converts 0..5 to
|
* Example: to simulate a d6 use `SDL_rand_n(6) + 1` The +1 converts 0..5 to
|
||||||
* 1..6
|
* 1..6
|
||||||
*
|
*
|
||||||
* If you want reproducible output, be sure to initialize with SDL_srand() first.
|
* If you want reproducible output, be sure to initialize with SDL_srand()
|
||||||
|
* first.
|
||||||
*
|
*
|
||||||
* There are no guarantees as to the quality of the random sequence produced,
|
* There are no guarantees as to the quality of the random sequence produced,
|
||||||
* and this should not be used for security (cryptography, passwords) or where
|
* and this should not be used for security (cryptography, passwords) or where
|
||||||
@@ -1324,8 +1325,7 @@ extern SDL_DECLSPEC Uint32 SDLCALL SDL_rand_bits(void);
|
|||||||
* of those to meet any serious needs.
|
* of those to meet any serious needs.
|
||||||
*
|
*
|
||||||
* \param n the number of possible outcomes. n must be positive.
|
* \param n the number of possible outcomes. n must be positive.
|
||||||
*
|
* \returns a random value in the range of [0 .. n-1].
|
||||||
* \returns a random value in the range of [0 .. n-1]
|
|
||||||
*
|
*
|
||||||
* \threadsafety All calls should be made from a single thread
|
* \threadsafety All calls should be made from a single thread
|
||||||
*
|
*
|
||||||
@@ -1339,7 +1339,8 @@ extern SDL_DECLSPEC Sint32 SDLCALL SDL_rand_n(Sint32 n);
|
|||||||
/**
|
/**
|
||||||
* Generates a uniform pseudo-random floating point number less than 1.0
|
* Generates a uniform pseudo-random floating point number less than 1.0
|
||||||
*
|
*
|
||||||
* If you want reproducible output, be sure to initialize with SDL_srand() first.
|
* If you want reproducible output, be sure to initialize with SDL_srand()
|
||||||
|
* first.
|
||||||
*
|
*
|
||||||
* There are no guarantees as to the quality of the random sequence produced,
|
* There are no guarantees as to the quality of the random sequence produced,
|
||||||
* and this should not be used for security (cryptography, passwords) or where
|
* and this should not be used for security (cryptography, passwords) or where
|
||||||
|
|||||||
Reference in New Issue
Block a user