PHP随机浮点数random float

function random_float() {
    return (float)mt_rand() / (float)mt_getrandmax();
}
function random_float() {
    return (float)rand() / (float)getrandmax();
}
function random_float($min = 0, $max = 1) {
    return random_int($min, $max - 1) + (random_int(0, PHP_INT_MAX - 1) / PHP_INT_MAX );
}
function random_float($min = 0, $max = 1) {
    return $min + mt_rand() / mt_getrandmax() * ($max - $min);
}
赞(0)
未经允许不得转载:PHPez » PHP随机浮点数random float

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址