Clarity on behaviour of mt_getrandmax() and mt_rand()'s max

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@335710 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Andrea Faulds 2015-01-11 01:55:26 +00:00
parent d69425501f
commit e36faa1eae
2 changed files with 7 additions and 1 deletions

View file

@ -19,7 +19,10 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns the maximum random value returned by <function>mt_rand</function>
Returns the maximum random value returned by a call to
<function>mt_rand</function> without arguments, which is the maximum value
that can be used for its <function>max</function> parameter without the
result being scaled up (and therefore less random).
</para>
</refsect1>
<refsect1 role="examples">

View file

@ -124,6 +124,9 @@ echo mt_rand(5, 15);
The distribution of <function>mt_rand</function> return values is biased
towards even numbers on 64-bit builds of PHP when
<parameter>max</parameter> is beyond <literal>2^32</literal>.
This is because if <parameter>max</parameter> is greater than
the value returned by <function>mt_getrandmax</function>, the output of the
random number generator must be scaled up.
</para>
</caution>
</refsect1>