summaryrefslogtreecommitdiff
path: root/manual
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-03-13 14:47:48 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-03-13 14:47:48 -0300
commit9eca305e75010e30342486a4139846faf1b3eccb (patch)
treedb2df6774e7c4eb63d2310772507c47e32223cdd /manual
parentc5feac2b5edf86aa9bdc4b8acd5380f2fe9e197f (diff)
downloadlua-github-9eca305e75010e30342486a4139846faf1b3eccb.tar.gz
'math.randomseed()' sets a somewhat random seed
When called with no arguments, 'math.randomseed' uses time and ASLR to generate a somewhat random seed. the initial seed when Lua starts is generated this way.
Diffstat (limited to 'manual')
-rw-r--r--manual/manual.of23
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)}.
The call @T{math.random(0)} produces an integer with
all bits (pseudo)random.
-Lua initializes its pseudo-random generator with
-a weak attempt for ``randomness'',
+Lua initializes its pseudo-random generator with the equivalent of
+a call to @Lid{math.randomseed} with no arguments,
so that @id{math.random} should generate
different sequences of results each time the program runs.
-To ensure a required level of randomness to the initial state
-(or contrarily, to have a deterministic sequence,
-for instance when debugging a program),
-you should call @Lid{math.randomseed} explicitly.
The results from this function have good statistical qualities,
but they are not cryptographically secure.
@@ -7660,14 +7656,23 @@ some number of previous results.)
}
-@LibEntry{math.randomseed (x [, y])|
+@LibEntry{math.randomseed ([x [, y]])|
-The integer parameters @id{x} and @id{y} are
-concatenated into a 128-bit @Q{seed} that
+When called with at least one argument,
+the integer parameters @id{x} and @id{y} are
+concatenated into a 128-bit @emphx{seed} that
is used to reinitialize the pseudo-random generator;
equal seeds produce equal sequences of numbers.
The default for @id{y} is zero.
+When called with no arguments,
+Lua generates a seed with
+a weak attempt for randomness.
+To ensure a required level of randomness to the initial state
+(or contrarily, to have a deterministic sequence,
+for instance when debugging a program),
+you should call @Lid{math.randomseed} with explicit arguments.
+
}
@LibEntry{math.sin (x)|