summaryrefslogtreecommitdiff
path: root/devdocs/elisp/random-numbers.html
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
committerCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
commit754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch)
treef1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/elisp/random-numbers.html
new repository
Diffstat (limited to 'devdocs/elisp/random-numbers.html')
-rw-r--r--devdocs/elisp/random-numbers.html9
1 files changed, 9 insertions, 0 deletions
diff --git a/devdocs/elisp/random-numbers.html b/devdocs/elisp/random-numbers.html
new file mode 100644
index 00000000..d68eebfd
--- /dev/null
+++ b/devdocs/elisp/random-numbers.html
@@ -0,0 +1,9 @@
+ <h3 class="section">Random Numbers</h3> <p>A deterministic computer program cannot generate true random numbers. For most purposes, <em>pseudo-random numbers</em> suffice. A series of pseudo-random numbers is generated in a deterministic fashion. The numbers are not truly random, but they have certain properties that mimic a random series. For example, all possible values occur equally often in a pseudo-random series. </p> <p>Pseudo-random numbers are generated from a <em>seed value</em>. Starting from any given seed, the <code>random</code> function always generates the same sequence of numbers. By default, Emacs initializes the random seed at startup, in such a way that the sequence of values of <code>random</code> (with overwhelming likelihood) differs in each Emacs run. </p> <p>Sometimes you want the random number sequence to be repeatable. For example, when debugging a program whose behavior depends on the random number sequence, it is helpful to get the same behavior in each program run. To make the sequence repeat, execute <code>(random "")</code>. This sets the seed to a constant value for your particular Emacs executable (though it may differ for other Emacs builds). You can use other strings to choose various seed values. </p> <dl> <dt id="random">Function: <strong>random</strong> <em>&amp;optional limit</em>
+</dt> <dd>
+<p>This function returns a pseudo-random integer. Repeated calls return a series of pseudo-random integers. </p> <p>If <var>limit</var> is a positive integer, the value is chosen to be nonnegative and less than <var>limit</var>. Otherwise, the value might be any fixnum, i.e., any integer from <code>most-negative-fixnum</code> through <code>most-positive-fixnum</code> (see <a href="integer-basics">Integer Basics</a>). </p> <p>If <var>limit</var> is <code>t</code>, it means to choose a new seed as if Emacs were restarting, typically from the system entropy. On systems lacking entropy pools, choose the seed from less-random volatile data such as the current time. </p> <p>If <var>limit</var> is a string, it means to choose a new seed based on the string’s contents. </p> </dd>
+</dl><div class="_attribution">
+ <p class="_attribution-p">
+ Copyright &copy; 1990-1996, 1998-2022 Free Software Foundation, Inc. <br>Licensed under the GNU GPL license.<br>
+ <a href="https://www.gnu.org/software/emacs/manual/html_node/elisp/Random-Numbers.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Random-Numbers.html</a>
+ </p>
+</div>