PDA

View Full Version : how do i generate a random php number in the billions?


Nullifi3d
04-19-2006, 11:06 AM
how do i generate a random number in the tens or even hundreds of billions? I have tried using rand & mt_rand, but once I get into ther tens of billions or even hundreds of billions (past rand_max) it returns negative numbers or numbers not in between the min and max specified.
if ($armyinfo['strike_action'] > 10000000) {
$armyinfo['damage'] = mt_rand((.75 * $armyinfo['strike_action']), (.95 * $armyinfo['strike_action']));
} elseif ($armyinfo['strike_action'] > 100000000) {
$armyinfo['damage'] = mt_rand((.80 * $armyinfo['strike_action']), (.95 * $armyinfo['strike_action']));
} elseif ($armyinfo['strike_action'] > 1000000000) {
$armyinfo['damage'] = mt_rand((.85 * $armyinfo['strike_action']), (.95 * $armyinfo['strike_action']));
} elseif ($armyinfo['strike_action'] > 10000000000) {
$armyinfo['damage'] = mt_rand((.90 * $armyinfo['strike_action']), (.95 * $armyinfo['strike_action']));
} else {
$armyinfo['damage'] = mt_rand((.70 * $armyinfo['strike_action']), (.95 * $armyinfo['strike_action']));
}