Mail Archives: djgpp/2000/05/25/01:23:54
Hello,
I have read what the function rand() is supposed to do, however it seems
to produce a very different response on my computer from what I would
expect.
If RAND_MAX is set to 100, then a call to rand() should return an
integer between 0 and 100. However, on my computer, a call to rand()
generates a number between what appears to be hundreds of millions and
0, even with RAND_MAX set to 100.
The computer I am using uses 4-byte integers (32-bit). Should I use
short integers instead? Alternatively, do I need to separately
recompile the library to include the changed RAND_MAX value rather than
just place it at the top of my *.h file? Or is there another function
that would be better to use, eg rand48?
Ideally, I am attempting to generate a random integer between 0 and
1,000,000.
Thank you in advance,
Chris Miller
- Raw text -