#

## random

Generate a random number or set a random seed.

### Usage:

> random [seed [value]]

> > where value is any integer.

### Summary:

> The random command with no arguments generates and returns a random integer value. With option seed and no additional argument, it sets the random seed value according to the current time. With option seed and additional argument value, it sets the random seed to the specified value.

> When used with option seed, no value is returned.

> Random numbers are generally frowned upon in layout because they can make certain things non-reproducible from run to run. Magic uses random numbers in only one very restricted circumstance, for GDS output. The use in GDS output is restricted to the single circumstance of writing an entire GDS file due to use of the "GDS_FILE" property in a cell with a "GDS_START" property value of "0". Because the GDS file may contain cells of unknown names, and these names could collide with names in the database, the GDS file cells are all prefixed with a random two-character string. To prevent the same prefix from being used on any run of magic, the random number generator should be appropriately seeded.

> Note that there is no random number seeding on startup of magic, so if needed, the random seed should be set in the startup file or on the command line.

### Implementation Notes:

> random is implemented as a built-in magic command.

### See Also:

> gds

Return to command index

Last updated: January 15, 2021 at 1:00pm