[ Arithmetic | Reference Manual | Alphabetic Index ]
# random(-N)

Generates a random integer N.
*N*
- Integer or Variable.

## Description

random/1 unifies N with a random integer between 0 and 2^31-1
(returned by the C library function random(), whose initialization
has been made using the pid of the running ECLiPSe ).
If it is required that the sequence produced by successive calls of
random/1 be reproducible, seed(Seed) can be called to initialise the
calls with the integer Seed. Do not assume that the same sequence will
be produced for the same seed on different platforms, because the C
library's implementation of random() may differ.

### Modes and Determinism

### Exceptions

*(5) type error *
- N is instantiated, but not to an integer.

## Examples

Success:
?- random(N1), random(N2).
N1 = 464880439
N2 = 285401533
yes.
?- seed(1), random(N).
N = 2078917053
yes.
?- seed(1), random(N).
N = 2078917053
yes.
Fail:
random(12345).
Error:
random(12.34). (Error 5).

## See Also

frandom / 1, seed / 1