Re: $max > getmaxrand() for rand() call
| From: | Stanislav Malyshev | Date: | Mon, 13 Apr 2015 03:23:51 +0000 |
| Subject: | Re: $max > getmaxrand() for rand() call | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-85777@lists.php.net to get a copy of this message | ||
Hi!
> <https://bugs.php.net/bug.php?id=69396>) - to sum up: if
> you provide
> $max parameter that is larger than OS-provided getmaxrand(), the
> result will be artificially stretched, which in result leads to some
> values not appearing at all. That’s troublesome if for instance some
> people use that function to choose random server for a service, and
> the stretched result wouldn’t return even values at all.
How many servers you've got? Also, why not use mt_rand()? It has max of
2^^31, if you have more servers than that you probably have very
uncommon use case :)
--
Stas Malyshev
smalyshev@gmail.com