PHP随机浮点数

function randomFloat($min = 0, $max = 1) {
	$rand = mt_rand();
	$lmax = mt_getrandmax();
  return  $min +  $rand / $lmax * ($max - $min);
}

var_dump(randomFloat());
var_dump(randomFloat(1, 100000));

随机浮点数函数!

posted @ 2014-03-04 18:10  老骆  阅读(848)  评论(0编辑  收藏  举报