dimanche 29 mars 2015

Does rand() ever return zero on OSX?

I have been running this code for almost ten hours with no love:



while ( true ) {
int r = rand();
assert( r != 0 );
}


I am expected rand() to eventually roll a zero and thus assert. I'm on a 2GHz machine if that makes any difference.


Am I doing something wrong or does rand() never return zero? Or have I not been waiting long enough to expect to see it?





Aucun commentaire:

Enregistrer un commentaire