samedi 7 novembre 2015

Is that a good way to get random number?if not, why?

So i tried to create a "real" random function, because rand wasn't random enough imo.

Do you think that it's a "good" way to get random numbers?if not, why?

int realrand() {
  double duration = 0;
  int i = 0;
  std::clock_t start;
  start = std::clock();

  while(duration < 0.001) {
    i++;
    duration = ( std::clock() - start ) / (double) CLOCKS_PER_SEC;
  }

  int rand = i % 10;

  return rand;
}




Aucun commentaire:

Enregistrer un commentaire