Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Force 4.0 Reference - randomnum() return a random number in an interval http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 randomnum()         Return a random number in an interval
------------------------------------------------------------------------------
 Declaration
   math.hdr

 Syntax
   func long randomnum extern
   param value long nMin, ;
         value long nMax

 Arguments
   nMin is the lower limit of the interval for generating a
   random number.

   nMax is the upper limit of the interval for generating a
   random number.

 Return
   A random number within the given interval.

 Description
   The randomnum() function returns a random number that falls within
   the range specified by the two parameters.

 Example
   #define EXAMPLE_MATH
   #include example.hdr

   proc Test_randomnum
   vardef
      ulong n
   enddef
   randomize()                          // initialize random generator
   for n := 1 to 10
      ? randomnum( 10, 90 )             // 10 numbers between 10 and 90
   next
   ?
   for n := 1 to 10
      ? randomnum( -9140100, -9140000 ) // 10 negative numbers
   next
   endproc

   proc main
   Test_randomnum()
   endproc

See Also: randomize()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson