# $random(5)

[Home] [Commands] [Variables] [Macro-Dev] [Glossary]

## NAME

$random - Generate a random number

## SYNOPSIS

`$random` integer

0 <= integer <= 65535

## DESCRIPTION

The $random variable returns a unique random number in the range 0 - n on reference to the variable.

The random number is derived from the system's random number generator (the quality of which is often dubious so try to avoid using the bottom bits). Setting this variable with any value resets the random sequence using the system time as the seed.

The range of the random number generator is system dependent. The value is typically capped using the &mod(4) arithmetic operator.

## EXAMPLE

The variable may be assigned to generate a new seed as follows:-

    set-variable $random 0        ; Set it so we get a new seed

The returned value is used with the &mod operator to limit the value to a desired range:-

    set-variable %random0to9 &mod $random 10

## SEE ALSO

&mod(4).

(c) Copyright JASSPA 2009
Last Modified: 2009/08/29
Generated On: 2009/10/12

</HMTL>