Created
April 27, 2020 09:51
-
-
Save blood72/1e22a0875131b3c14fd2ddc3708e7833 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?php | |
if (! function_exists('random_float')) { | |
/** | |
* Generates random float number. | |
* | |
* @param int|float $min | |
* @param int|float $max | |
* @param int $digit | |
* @return float|int | |
* @throws \Exception | |
*/ | |
function random_float($min, $max, int $digit = 10) { | |
$pow = pow(10, $digit); | |
return mt_rand($min * $pow, $max * $pow) / $pow; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment