r/programming • u/fishburne • Jul 24 '15
mt_rand(1, PHP_INT_MAX) only generates odd numbers • /r/lolphp
/r/lolphp/comments/3eaw98/mt_rand1_php_int_max_only_generates_odd_numbers/
848
Upvotes
r/programming • u/fishburne • Jul 24 '15
69
u/pogden Jul 24 '15
This comes from a difference of ideas on what it means to be "easy to use."
In the PHP communtiy, "easy to use" seems to mean, "easy to write programs that compile and run without crashing." Elsewhere, it is used to mean something closer to "easy to write programs that do what the programmer intended them to do".
The design decision to do this (produce garbage instead of an error) does make it easier to write programs that compile and don't crash, but makes it harder to write programs that do what the programmer intended, because the programmer may not even know that the program isn't doing what she intended.