home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2004 March / PCWELT_3_2004.ISO / pcwsoft / flaskmpeg_078_39_src.z.exe / flaskmpeg / FlRandom.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2002-10-28  |  726 b   |  35 lines

  1. // FlRandom.cpp: implementation of the FlRandom class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4.  
  5. #include "FlRandom.h"
  6.  
  7. //////////////////////////////////////////////////////////////////////
  8. // Construction/Destruction
  9. //////////////////////////////////////////////////////////////////////
  10.  
  11. FlRandom::FlRandom()
  12. {
  13.   // Initialize random generator variables
  14.   randx = 1;
  15.   z = (double) 0x7fffffff;
  16. }
  17.  
  18. FlRandom::~FlRandom()
  19. {
  20.  
  21. }
  22.  
  23. /* Pseudo-random generator */
  24. long FlRandom::Random(long L, long H)
  25. {
  26.   long i,j;
  27.   double x;
  28.  
  29.   randx = (randx * 1103515245) + 12345;
  30.   i = randx & 0x7ffffffe;
  31.   x = ((double) i) / z;
  32.   x *= (L+H+1);
  33.   j = (long)x;
  34.   return j-L;
  35. }