home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pmos2002.zip / DEF / RANDCARD.DEF < prev    next >
Text File  |  1996-10-08  |  1KB  |  31 lines

  1. DEFINITION MODULE RandCard;
  2.  
  3.         (********************************************************)
  4.         (*                                                      *)
  5.         (*              Random number generator                 *)
  6.         (*                                                      *)
  7.         (*  Programmer:         P. Moylan                       *)
  8.         (*  Last edited:        25 June 1996                    *)
  9.         (*  Status:             OK                              *)
  10.         (*                                                      *)
  11.         (********************************************************)
  12.  
  13. CONST modulus = 2147483647;     (*  2^31 - 1  *)
  14.  
  15. VAR seed: CARDINAL;     (*   visible in case you want to re-randomize   *)
  16.  
  17. PROCEDURE RandCardinal (): CARDINAL;
  18.  
  19.     (* Returns a random number in the range [1..modulus-1], with a      *)
  20.     (* uniform distribution over that range.                            *)
  21.  
  22. PROCEDURE RandInt (min, max: INTEGER): INTEGER;
  23.  
  24.     (* Returns a random number in the range [min..max]          *)
  25.     (* (inclusive), with an approximately uniform distribution  *)
  26.     (* over that range.  (In this version I'm not being fussy   *)
  27.     (* about the precise distribution.)                         *)
  28.  
  29. END RandCard.
  30.  
  31.