vendredi 24 juillet 2015

Why does mt_rand(1, PHP_INT_MAX) always return an odd number [HackerNews]

I've just come across an interesting question from ComputerGuru on Hacker News and no comment seems to give a convincing answer.

Why does mt_rand(1, PHP_INT_MAX) always return an odd number?

I am not the author of the original question.

http://3v4l.org/dMbat

for ($i=0;$i<10000;$i++)
{
    echo mt_rand(1, PHP_INT_MAX)."\n";
}

output:

8571620074060775425
7401021871338029057
4351677773593444353
1801559362708176897
7848614552286527489
...




Aucun commentaire:

Enregistrer un commentaire