Re: ext-random: add random_float() ?

From: Date: Tue, 20 Dec 2022 08:06:56 +0000
Subject: Re: ext-random: add random_float() ?
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-119189@lists.php.net to get a copy of this message
>returns a value between 0.0 and 1.0. wouldn't it be better to follow random_int(int $min, int $max) design? eg random_float(float $min, float $max): float On Tue, 20 Dec 2022 at 07:27, Go Kudo <g-kudo@colopl.co.jp> wrote: > > Hi Internals. > > Congratulations on the release of PHP 8.2. > I just recently upgraded production PHP from 7.4 to 8.1 :) > > Now that my work is done, I was thinking about a proposal for a sunsetting > of existing functions for PHP 8.3 based on the features introduced in > ext-random, and I realized that there is no alternative to > lcg_value(). > > Essentially, this could be completely replaced by > Random\Randomizer::getFloat(), but there are easier > random_int() and > random_bytes() functions for ints and strings. > > The Randomizer may be overkill and complicated for PHP use cases where > random number reproducibility is not required in many cases. > > So, why not add a random_float(): float function? This > function, like the > others, uses CSPRNG and returns a value between 0.0 and 1.0. This behavior > is Closed Closed. > > Opinions are welcome. > > Regards, > Go Kudo

« previous php.internals (#119189) next »