home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / simtel / sigm / vols000 / vol080 / random.psp < prev    next >
Encoding:
Text File  |  1985-02-10  |  768 b   |  22 lines

  1. FUNCTION Random (VAR Seed : Integer) : Real ;
  2.  
  3.   { Taken from PROGRAMMING IN PASCAL, by Peter Grogono, pp. 117-119,
  4.     with "Modulus" reduced to "Maxint" to accommodate Pascal/Z limits.
  5.     Returns a pseudo-random number between 0 and 1.0, inclusive, and
  6.     should generate "Maxint" (32767) such numbers before repeating itself. }
  7.  
  8.   CONST
  9.     Multiplier    = 25173 ;
  10.     Increment    = 13849 ;
  11.  
  12. BEGIN { Random }
  13.  
  14.   Random := Seed / Maxint ;
  15.   Seed := Abs ((Seed * Multiplier + Increment) MOD Maxint) ;
  16.  
  17. END { Random } ;
  18. N { Random }
  19.  
  20.   Random := Seed / Maxint ;
  21.   Seed := Abs ((Seed * Multiplier + Increment) MOD Maxint) ;!╬═╖┬Æ═P═î├Q!µ═╖┬¬═P═}═Qx├Q!Ω═╖┬╞═█═ôG@═█▒░├Q!
  22. ═╖┬▄y═ôGÇ├╛!═╖┬⌠ ═█═ô▒├Q!═╖┬═