[next] [previous] [contents]

  11.1.1.6 RND Function
  The RND function returns a number greater than or equal
  to zero and less than 1. The RND function always returns
  a floating-point number of the default floating-point data
  type. The RND function generates seemingly unrelated
  numbers. However, given the same starting conditions, a
  computer always gives the same results. Each time you exe-
  cute a program with the RND function, you receive the same
  results.
  PRINT RND,RND,RND,RND
  END

  Output 1
    .76308 .179978 .902878 .88984

  Output 2
    .76308 .179978 .902878 .88984
  With the RANDOMIZE statement, you can change the RND
  function's starting condition and generate random numbers.
  To do this, place a RANDOMIZE statement before the line
  invoking the RND function. Note that the RANDOMIZE
  statement should be used only once in a program. With the
  RANDOMIZE statement, each invocation of RND returns a
  new and unpredictable number.
  RANDOMIZE
  PRINT RND,RND,RND,RND
  END

  Output 1
    .403732 .34971 .15302 .92462

  Output 2
    .404165 .272398 .261667 .10209
  The RND function can generate a series of random num-
  bers over any open range. To produce random numbers in
  the open range A to B , use the following formula:
  (B-A)*RND + A

  The following program produces 10 numbers in the open
  range 4 to 6:
  FOR I% = 1% TO 10%
        PRINT (6%-4%) * RND + 4
  NEXT I%
  END

  Output
    5.52616
    4.35996
    5.80576
    5.77968
    4.77402
    4.95189
    5.76439
    4.37156
    5.2776
    4.53843