12/25/2007

Pseudorandom number generation enhanced in VS2005

1. Define the _CRT_RAND_S macro before the #include <stdlib.h> .
2. Does not need call srand function to generate the seed.
3. rans_s now has returned value which is type of errno_t, zero if successful.
4. Use this formula: dst_num = (unsigned int)((double)rand_num / (double)UINT_MAX * rand_max + rand_min) to specify the range[rand_min, rand_max] .


No comments: