home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / beehive / utilitys / random.arc / RANDOM.LST < prev   
File List  |  1990-07-21  |  896b  |  38 lines

  1.  
  2. LISTING 1
  3.  
  4. program...
  5.  
  6. var
  7.    x, y, z: integer; { global seeds }
  8. . . .
  9. funtion random: real;
  10.     var
  11.         temp: real;
  12.     begin
  13.     { first generator }
  14.     x := 171 * (x mod 177) - 2 * (x div 177);
  15.     if x < 0 then
  16.        x := x + 30269;
  17.     { second generator }
  18.     y :=172 * (y mod 176) - 35* (y div 176);
  19.     if y < 0 then
  20.        y :=y + 30307
  21.     { third generator }
  22.     z := 170 * (z mod 178) - 63* (z div 178);
  23.     if z  < 0 then
  24.        z := z + 30323
  25.     { combine to give function value }
  26.     temp := x/30269.0 + y/30307.0 + z/30323.0;
  27.     random := temp - trunc(temp)
  28.     end;
  29.     ...
  30. begin
  31.  
  32. { initializse seeds.  For production runs, different
  33.  values (between 1 and 30000) should be used each time,
  34. preferably by some automatic method such as from date
  35. and time readings if available }
  36. x :=1; y := 10000; z:= 3000;
  37. ...
  38. end