Skip to content

RANDOMIZE

Syntax

RANDOMIZE [<expression>]

Purpose

To reseed the random number generator.

Remarks

If is omitted, BASIC-80 suspends program execution and asks for a value by printing Random Number Seed (-32768 to 32767)? before executing RANDOMIZE. If the random number generator is not reseeded, the RND function returns the same sequence of random numbers each time the program is RUN. To change the sequence of random numbers every time the program is RUN, place a RANDOMIZE statement at the beginning of the program and change the argument with each RUN.

Example

10 RANDOMIZE
20 FOR I=1 TO 5
30 PRINT RND;
40 NEXT I

RUN
Random Number Seed (-32768 to 32767)? 3
.88598 .484668 .586328 .119426 .709225
Ok

RUN
Random Number Seed (-32768 to 32767)? 4
.803506 .162462 .929364 .292443 .322921
Ok

RUN
Random Number Seed (-32768 to 32767)? 3
.88598 .484668 .586328 .119426 .709225
Ok

Note: Using the same seed (3) produces the same sequence of random numbers.

See Also

  • RND - Generate random numbers
  • INT - Convert to integer for random ranges