Go to the previous, next section.
In a computer, 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.
In Emacs, pseudo-random numbers are generated from a "seed" number.
Starting from any given seed, the random function always
generates the same sequence of numbers. Emacs always starts with the
same seed value, so the sequence of values of random is actually
the same in each Emacs run! For example, in one operating system, the
first call to (random) after you start Emacs always returns
-1457731, and the second one always returns -7692030. This is helpful
for debugging.
If you want truly unpredictable random numbers, execute (random
t). This chooses a new seed based on the current time of day and on
Emacs' process ID number.
Function: random &optional limit
This function returns a pseudo-random integer. When called more than once, it returns a series of pseudo-random integers.
If limit is nil, then the value may in principle be any
integer. If limit is a positive integer, the value is chosen to
be nonnegative and less than limit (only in Emacs 19).
If limit is t, it means to choose a new seed based on the
current time of day and on Emacs's process ID number.
On some machines, any integer representable in Lisp may be the result
of random. On other machines, the result can never be larger
than a certain maximum or less than a certain (negative) minimum.
Go to the previous, next section.