Google
 

Sunday, December 16, 2007

Return Random Float

An elegant way to return random float between two numbers:

example:
<?php
function random_float ($min,$max) {
return ($min+lcg_value()*(abs($max-$min)));
}
?>

<?php
function random_float ($min,$max) {
return max($min, lcg_value() * $max);
}
?>