NAME

trand - return a random integer within a specified range


SYNOPSIS

value = trand([minimum,] maximum)

Parameters inside the [brackets] are optional.


DESCRIPTION

Call trand to get a random integer that falls within the range specified by the arguments.

It's a good idea to call srand once to seed the random number generator before using trand. Otherwise, a seed of 1 will be used.


ARGUMENTS
minimum[optional], maximum
These arguments define the range within which falls the random value returned by trand. trand includes the lower bound in output, but the upper bound is non-inclusive (i.e. trand will return maximum - 1 as a high value). If minimum is not present, trand will return an integer value between 0 and maximum - 1.


EXAMPLES
   srand(0)
   min = -30
   max = 10
   for (i = 0; i < 20; i = i + 1) {
      randval = trand(min, max)
      print(randval)
   }
another useful example:
   array = { 1, 2, 3, 4, 5, 6, 7 }
   len_array = len(array)
   for (i = 0; i < 14; i += 1) {
      val = array[trand(len_array)]
   }


SEE ALSO

irand, srand, random, rand, pickrand, pickwrand, spray_init, get_spray, maketable("random")