Looping through rm_rand, storing highest and lowest values
Posted: Fri Dec 29, 2006 12:21 pm
I have just wrote a little script that generates 1,000,000 random numbers using rm_rand and stores the highest and lowest values generated. It seems to work in the fact the highest is always higher than the lowest but I unexplainable feeling that it's not working correctly.
Could somebody tell me if this is working as it should be:
Could somebody tell me if this is working as it should be:
Code: Select all
$i = 0;
while ($i < 1000000) {
if (isset($rand)) {
$rand2 = $rand;
}
$rand = mt_rand();
if (isset($rand2)) {
if ($rand < $rand2) {
$lowest = $rand;
}
if ($rand > $rand2) {
$highest = $rand;
}
}
$i++;
}
echo "The lowest random number generated was: ", $lowest, "\n";
echo "The highest random number generated was: ", $highest, "\n";