Created
December 28, 2018 08:31
-
-
Save sooch/6eea320aa5111af8f56dfeb24893f9c7 to your computer and use it in GitHub Desktop.
random number between a float range for PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 範囲内の値をランダムで返す | |
* | |
* @param float $min 最小値 | |
* @param float $max 最大値 | |
* @return float | |
*/ | |
function random_float($min, $max, $mul = 1000000): float | |
{ | |
return random_int($min * $mul, $max * $mul) / $mul; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment