B
Bill Burris
Hi,
With VS .NET 2003 the rand() function sometimes returns a number equal to
RAND_MAX. The docs say: The rand function returns a pseudorandom integer in
the range 0 to RAND_MAX. Does this mean that 0 & RAND_MAX are included in
the range?
I am asking because I was using code from a book, which was developed on
Linux. The program occasionally dies, because the random number is used in
calculating an array index. It seems that the Linux version of rand()
returns a number less than RAND_MAX.
I am curious to know if this is a bug in the Windows or Linux version of
srand(), or they just like to be different. Or is the bug in the code from
the book?
The C# docs for Random.Next() are a little more clear:
A 32-bit signed integer greater than or equal to zero and less than
MaxValue.
Bill
With VS .NET 2003 the rand() function sometimes returns a number equal to
RAND_MAX. The docs say: The rand function returns a pseudorandom integer in
the range 0 to RAND_MAX. Does this mean that 0 & RAND_MAX are included in
the range?
I am asking because I was using code from a book, which was developed on
Linux. The program occasionally dies, because the random number is used in
calculating an array index. It seems that the Linux version of rand()
returns a number less than RAND_MAX.
I am curious to know if this is a bug in the Windows or Linux version of
srand(), or they just like to be different. Or is the bug in the code from
the book?
The C# docs for Random.Next() are a little more clear:
A 32-bit signed integer greater than or equal to zero and less than
MaxValue.
Bill