home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_02_08 / 2n08056a < prev    next >
Text File  |  1991-06-10  |  384b  |  22 lines

  1. /*
  2.     Random number generator used by the standard
  3.     library for the Microsoft C compiler version 5.1.
  4. */
  5.  
  6. static unsigned long seed;
  7.  
  8. void srand(int iseed)
  9. {
  10.     seed = (unsigned long) iseed << 16;
  11. }
  12.  
  13. int rand()
  14. {
  15.     /*
  16.     **    incidental mod of 2^32 by ignoring
  17.     **    overflow during multiply and add
  18.     */
  19.     seed = seed * 214013L + 2531011L;
  20.     return ((seed >> 16) & 0x7FFF);
  21. }
  22.