1
2
3
4
5
6
7
|
function
randomFloat( $min
= 0, $max
= 1) {
$rand
= mt_rand();
$lmax
= mt_getrandmax();
return
$min + $rand
/ $lmax * ( $max - $min );
} var_dump(randomFloat());<br>var_dump(randomFloat(1, 100000)); |
随机浮点数函数!