home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c017 / 7.ddi / GPPLIB.ZIP / RNG.CC < prev    next >
Encoding:
C/C++ Source or Header  |  1988-08-17  |  569 b   |  25 lines

  1. #include "RNG.h"
  2. #include "assert.h"
  3.  
  4. //
  5. //    The scale constant is 2^-31. It is used to scale a 31 bit
  6. //    long to a double.
  7. //
  8.  
  9. const double randomDoubleScaleConstant = 4.656612873077392578125e-10;
  10. const float  randomFloatScaleConstant = 4.656612873077392578125e-10;    
  11.  
  12. unsigned long RNG::asLong()
  13. {
  14.     assert2(0,"subClassResponsibility");
  15.     return(0);
  16. }
  17.  
  18. float RNG::asFloat() {
  19.     return( (asLong() & 0x7fffffff) * randomFloatScaleConstant);
  20. }
  21.     
  22. double RNG::asDouble() {
  23.     return( (asLong() & 0x7fffffff) * randomDoubleScaleConstant);
  24. }
  25.