an open-source digital signal processing and sound synthesis language
about · links · contact
irand - return a random number within a specified range


value = irand([minimum,] maximum)

Parameters inside the [brackets] are optional.


Call irand to get a random number 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 irand. Otherwise, a seed of 1 will be used.


minimum [optional], maximum
These arguments define the range within which falls the random value returned by irand. If minimum is not present, irand will return a value between 0.0 and maximum. The bounds are inclusive.


   min = -30
   max = 10
   for (i = 0; i < 20; i = i + 1) {
      randval = irand(min, max)

See Also

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