You are looking at historical revision 34052 of this page. It may differ significantly from its current revision.
Module (chicken process-context)
This module provides a (weak) pseudo random number generator.
randomize
[procedure] (randomize [SEED])Set random-number seed. If SEED (an exact integer) is not supplied, the current time is used. On startup (when Unit extras is initialized), the random number generator is initialized with the current time.
random
[procedure] (random N)Returns a pseudo-random integer in [0, N-1]. N is an integer.
On Windows, N and the random value are exact integer.
Warning: This procedure uses rand(3) internally and exhibits its deficiencies, including low quality pseudo-randomness:
- On Windows and Solaris, only 32768 unique random values can be generated in the range [0, N-1]. If N >= 32768, there will be gaps in the result set.
- On Mac OS X, Windows and some other platforms, little variance in output is seen with nearby seeds. Since the random generator is seeded with current-seconds at startup, new processes may see similar or identical random sequences for up to a minute.
- On Linux, rand(3) is an alias to random(3), which provides output of reasonable quality.
Previous: Module (chicken process-context)