src/NumberGenerator.php
public function getFloat($min, $max)
    {
        if ($min > $max) {
            throw new InvalidArgumentException('Min cannot be greater than max');
        }

        $random01 = \mt_rand() / \mt_getrandmax();

        // [0, 1] -> [min, max]:
        // y = (max - min) * x + min
        return ($max - $min) * $random01 + $min;
    }
public function getFloat($min, $max)
    {
        if ($min > $max) {
            throw new InvalidArgumentException('Min cannot be greater than max');
        }

        $random01 = \mt_rand() / \mt_getrandmax();

        // [0, 1] -> [min, max]:
        // y = (max - min) * x + min
        return ($max - $min) * $random01 + $min;
    }
public function getFloat ( $ min , $ max ) { if ( $ min > $ max ) { throw new InvalidArgumentException ( 'Min cannot be greater than max' ) ; } $ random01 = \ mt_rand ( ) / \ mt_getrandmax ( ) ; // [0, 1] -> [min, max]: // y = (max - min) * x + min return ( $ max - $ min ) * $ random01 + $ min ; }
Returns random float from given range.

@param float $min The minimal value.
@param float $max The maximal value.

@return float

@throws InvalidArgumentException If min is greater than max.
Returns random float from given range .