Quote:
Originally Posted by ke121885
I am trying to print the value of RAND_MAX with this code:
Code:
#include <stdio.h>
#include <stdlib.h>
/*
* Main Function
*
*/
main(void)
{
printf("RAND_MAX = %d\n", RAND_MAX);
}
It is giving a number that is much larger than the 32767 that it is supposed to....any help?
|
Where are you getting the information about what RAND_MAX is "supposed to be"? It is what it is.
And what did the program print on your system? Didn't it occur to you that this would be useful for any meaningful reply?
32767 is 2^15-1. That is tiny by modern standards. It is virtually certain to not be the value of RAND_MAX, which is typically an unsigned value one less than the system's word length -- for a 32-bit machine that would be:
2^32-1 = 4294967295
Or, for a 64-bit machine:
2^64-1 = 18446744073709551615