[ ECLiPSe Arithmetic built-in.|Group Index| Full 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 to the power of 32 minus 1 (returned by the random C library function, 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.

Fail Conditions

None.

Resatisfiable

No.

Exceptions

(5) Type error
N is instantiated, but not to an integer.

Examples


Success:
      [eclipse]: random(N1), random(N2).
      N1 = 464880439
      N2 = 285401533
      yes.

      [eclipse]: seed(1), random(N).
      N = 2078917053
      yes.
      [eclipse]: seed(1), random(N).
      N = 2078917053
      yes.

Fail:
      random(12345).

Error:
      random(12.34).          (Error 5).


See Also

frandom / 1, seed / 1