svn: /phpdoc/en/trunk/reference/math/functions/ mt-getrandmax.xml
| From: | Justin Martin | Date: | Fri, 05 Nov 2010 23:47:06 +0000 |
| Subject: | svn: /phpdoc/en/trunk/reference/math/functions/ mt-getrandmax.xml | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-7373@lists.php.net to get a copy of this message | ||
frozenfire Fri, 05 Nov 2010 23:47:06 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=305119
Log:
Added an example to the Math extension's mt_getrandmax function, as per bug #53207.
Bug: http://bugs.php.net/53207 (Assigned) Missing Example
for mt_getrandmax
Changed paths:
U phpdoc/en/trunk/reference/math/functions/mt-getrandmax.xml
Modified: phpdoc/en/trunk/reference/math/functions/mt-getrandmax.xml
===================================================================
--- phpdoc/en/trunk/reference/math/functions/mt-getrandmax.xml 2010-11-05 23:32:06 UTC (rev 305118)
+++ phpdoc/en/trunk/reference/math/functions/mt-getrandmax.xml 2010-11-05 23:47:06 UTC (rev 305119)
@@ -22,6 +22,32 @@
Returns the maximum random value returned by <function>mt_rand</function>
</para>
</refsect1>
+ <refsect1 role="examples">
+ &reftitle.examples;
+ <para>
+ <example><title>Calculate a random floating-point number</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+function randomFloat($min = 0, $max = 1) {
+ return $min + mt_rand() / mt_getrandmax() * ($max - $min);
+}
+
+var_dump(randomFloat());
+var_dump(randomFloat(2, 20));
+?>
+]]>
+ </programlisting>
+ &example.outputs;
+ <screen>
+<![CDATA[
+float(0.91601131712832)
+float(16.511210331931)
+]]>
+ </screen>
+ </example>
+ </para>
+ </refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>