Why does rand() repeat numbers far more often on Linux than Mac?
问题 I was implementing a hashmap in C as part of a project I'm working on and using random inserts to test it. I noticed that rand() on Linux seems to repeat numbers far more often than on Mac. RAND_MAX is 2147483647/0x7FFFFFFF on both platforms. I've reduced it to this test program that makes a byte array RAND_MAX+1 -long, generates RAND_MAX random numbers, notes if each is a duplicate, and checks it off the list as seen. #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time