Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
poizan42
on July 24, 2015
|
parent
|
context
|
favorite
| on:
A call to PHP's mt_rand generates only odd numbers
Why not generate two values from the underlying function and shift them into place if the range is larger than 2^32 -1?
Oh well, ofc. because this is PHP which goes by the principle of most surprise.
TillE
on July 24, 2015
[–]
Yes, that's exactly what sensible RNG interfaces do, like std::random in C++. If your underlying engine only produces 32 bits at a time, it'll grab two of them when you request a 64-bit type.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search:
Oh well, ofc. because this is PHP which goes by the principle of most surprise.