note 2525 deleted from mt_rand by ronabop
| From: | ronabop@php.net | Date: | Wed, 13 Sep 2000 16:25:55 +0000 |
| Subject: | note 2525 deleted from mt_rand by ronabop | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-4830@lists.php.net to get a copy of this message | ||
BUG! (WinNT)<BR>
Setting min-max range doesn't work! I get values well beyond range.
<PRE>
echo "<B>mt_rand(0,20)=".mt_rand(0,20)."</B><BR>";
Actual results:
mt_rand(0,20)=879286
mt_rand(0,20)=1357383
mt_rand(0,20)=286308
etc...
</PRE>
A work-around using the % operator:
<PRE>
$randnum = ($mt_rand() % $maxVal-$minVal) + minVal;
</PRE>