home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / modu1096.zip / GPMsym / random.def < prev    next >
Text File  |  1996-09-03  |  2KB  |  41 lines

  1. (****************************************************************)
  2. (*                                                              *)
  3. (*         Gardens Point Modula-2 Library Definition            *)
  4. (*                                                              *)
  5. (*                                                              *)
  6. (*     (c) Copyright 1996 Faculty of Information Technology     *)
  7. (*              Queensland University of Technology             *)
  8. (*                                                              *)
  9. (*     Permission is granted to use, copy and change this       *)
  10. (*     program as long as the copyright message is left intact  *)
  11. (*                                                              *)
  12. (****************************************************************)
  13.  
  14. (* !LIBRARY! *) DEFINITION MODULE Random;
  15. (*
  16.   Random number generator.
  17.   Uses the 'Minimal standard random number generator' described by
  18.   Park & Miller, CACM 31,10,Oct 88 p1192. The code has been checked
  19.   for the 10001st random as specified in Park & Miller p1195.
  20.  
  21.   This version returns a REAL randomly distributed in the closed range
  22.   [0.0,1.0], and will be correct if the real mantissa is 46 bits
  23.   or larger (including sign bit). The sequence is guaranteed to produce
  24.   all values of the form n/m for n = 0 to m, where m is 2147483646
  25.   (=2**31-2), before cycling.
  26. *)
  27.  
  28. PROCEDURE InitRandom (seed : REAL);
  29. (* Initialise the random number generator with the given seed.        *)
  30. (* The seed should be in the range [1.0,2147483646.0] - values outside    *)
  31. (* this range are clamped to the extreme values.            *)
  32. (* If InitRandom is not called, the system clock is used to initialise    *)
  33. (* the sequence; thus InitRandom must be called to create a        *)
  34. (* reproducible sequence.                        *)
  35. (* InitRandom may be called as often as needed.                *)
  36.  
  37. PROCEDURE Random() : REAL;
  38. (* Return the next pseudo-random number in the closed range [0.0,1.0]    *)
  39.  
  40. END Random.
  41.