Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
673 B

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. vststutil.cxx
  5. Abstract:
  6. Implementation of CVsTstRandom class
  7. Brian Berkowitz [brianb] 06/08/2000
  8. TBD:
  9. Revision History:
  10. Name Date Comments
  11. brianb 06/08/2000 Created
  12. --*/
  13. #include <stdafx.h>
  14. #include <math.h>
  15. #include <vststutil.hxx>
  16. void CVsTstRandom::SetRandomSeed(UINT seed)
  17. {
  18. srand(seed);
  19. }
  20. UINT CVsTstRandom::RandomChoice(UINT low, UINT high)
  21. {
  22. UINT val = rand();
  23. double d = (double) (high - low);
  24. double m = (double) val/ (double) RAND_MAX;
  25. double res = d * m + .5;
  26. return (UINT) floor(res);
  27. }