note 18612 added to function.mt-rand
| From: | psychoborg at yahoo dot com | Date: | Tue, 29 Jan 2002 15:43:16 +0000 |
| Subject: | note 18612 added to function.mt-rand | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-25970@lists.php.net to get a copy of this message | ||
well, the rand function works, but looks like it has a limitation to it.
look at this :
function calcres($number)
{
global $Supplies;
srand ((double) microtime() * 1000000);
$retval = 0;
$a = 0;
if ($a!=$number)
{
do
{
$a++;
$tmp = rand(0,3+($roids+$retval));
if ($tmp<20) $retval++;
}while($a<$number);
}
return $retval;
}
Later it takes this random number and adds it to the data base fine. adding to the random numbers up
until you hit a specific point.
now, while this works fine, when you hit "32780" or around there in the data base(in this
case mySQL) you then get errors showing that the line is out of range. like the following:
Warning: rand(): Invalid range: 0..32780 in ..usr\inet\waves.php on line 20
What can be done to overcome this possible limitation?
My question is, would there be a workaround or fix to this limitation? or is this a limitation of
the rand() function? and not a bug in this programming structure.
--
http://www.php.net/manual/en/function.mt-rand.php
http://master.php.net/manage/user-notes.php?action=edit+18612
http://master.php.net/manage/user-notes.php?action=delete+18612
http://master.php.net/manage/user-notes.php?action=reject+18612