note 18692 deleted from function.mt-rand by bjori

From: Date: Sun, 16 Apr 2006 12:06:48 +0000
Subject: note 18692 deleted from function.mt-rand by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-108246@lists.php.net to get a copy of this message
Note Submitter: psychoborg at yahoo dot com ---- ok, an update to my last comment 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+ # the rand is limited in the function, Especcially with the current formula that im using here. but the fix is quite simple. just change the rand to mt_rand this will increase your random findings and stablize your php program, ($supplies+$retval)); if ($tmp<20) $retval++; }while($a<$number); } return $retval; } This function will work best with the mt_rand runction and not only that, it is most defanitly more stable. meaning you will not hit the limitation that will cause the SQL event out of range error.

« previous php.notes (#108246) next »