diff options
Diffstat (limited to 'manual')
-rw-r--r-- | manual/manual.of | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/manual/manual.of b/manual/manual.of index 2eb8773f..b47fd865 100644 --- a/manual/manual.of +++ b/manual/manual.of | |||
@@ -7643,14 +7643,10 @@ is equivalent to @T{math.random(1,n)}. | |||
7643 | The call @T{math.random(0)} produces an integer with | 7643 | The call @T{math.random(0)} produces an integer with |
7644 | all bits (pseudo)random. | 7644 | all bits (pseudo)random. |
7645 | 7645 | ||
7646 | Lua initializes its pseudo-random generator with | 7646 | Lua initializes its pseudo-random generator with the equivalent of |
7647 | a weak attempt for ``randomness'', | 7647 | a call to @Lid{math.randomseed} with no arguments, |
7648 | so that @id{math.random} should generate | 7648 | so that @id{math.random} should generate |
7649 | different sequences of results each time the program runs. | 7649 | different sequences of results each time the program runs. |
7650 | To ensure a required level of randomness to the initial state | ||
7651 | (or contrarily, to have a deterministic sequence, | ||
7652 | for instance when debugging a program), | ||
7653 | you should call @Lid{math.randomseed} explicitly. | ||
7654 | 7650 | ||
7655 | The results from this function have good statistical qualities, | 7651 | The results from this function have good statistical qualities, |
7656 | but they are not cryptographically secure. | 7652 | but they are not cryptographically secure. |
@@ -7660,14 +7656,23 @@ some number of previous results.) | |||
7660 | 7656 | ||
7661 | } | 7657 | } |
7662 | 7658 | ||
7663 | @LibEntry{math.randomseed (x [, y])| | 7659 | @LibEntry{math.randomseed ([x [, y]])| |
7664 | 7660 | ||
7665 | The integer parameters @id{x} and @id{y} are | 7661 | When called with at least one argument, |
7666 | concatenated into a 128-bit @Q{seed} that | 7662 | the integer parameters @id{x} and @id{y} are |
7663 | concatenated into a 128-bit @emphx{seed} that | ||
7667 | is used to reinitialize the pseudo-random generator; | 7664 | is used to reinitialize the pseudo-random generator; |
7668 | equal seeds produce equal sequences of numbers. | 7665 | equal seeds produce equal sequences of numbers. |
7669 | The default for @id{y} is zero. | 7666 | The default for @id{y} is zero. |
7670 | 7667 | ||
7668 | When called with no arguments, | ||
7669 | Lua generates a seed with | ||
7670 | a weak attempt for randomness. | ||
7671 | To ensure a required level of randomness to the initial state | ||
7672 | (or contrarily, to have a deterministic sequence, | ||
7673 | for instance when debugging a program), | ||
7674 | you should call @Lid{math.randomseed} with explicit arguments. | ||
7675 | |||
7671 | } | 7676 | } |
7672 | 7677 | ||
7673 | @LibEntry{math.sin (x)| | 7678 | @LibEntry{math.sin (x)| |