Menu

#343 Windows rand() returns [0, 32767]

For_2.1
open
nobody
rand (1)
5
2014-12-02
2014-12-02
Feiyun Wang
No

See http://msdn.microsoft.com/en-us/library/398ax69y.aspx
The rand function returns a pseudorandom integer in the range 0 to RAND_MAX (32767).

As for rand() in win32select.c, I don't think values between 0 and 32767 are expected while the max TCP port number exceeds this limit.
As for rand_init(50000) in test/test-time.c, it will be rand()%50000 and yield a value between 0 and 32767, which does not work as expected either.

Discussion


Log in to post a comment.

MongoDB Logo MongoDB