Am 11.05.2021 um 23:20 schrieb Larry Garfield <la...@garfieldtech.com>: > 3) Perhaps it should be named RandomSequence or similar? It's not truly > generating random numbers. It's generating a repeatable but difficult to > produce sequence off of a seed value. That's not the same thing as > random_int() et al. > > So, at first pass, an API could be as simple as (pseudocode): > > class RandomSequence { > public function __construct(int $seed = time(), $algorithm = 'some_default') > { ... } > > public function next(): int { ... } > } > > And that's it. That's nice and simple and predictable to use.
Would the generated values fill the whole int range, i.e. 64 bit on modern systems? And would it make sense to add max and min for the generated values like we have with random_int()? Because mapping arbitrary int values to a specific range is error-prone: Just using modulo leads to bias in the resulting values. - Chris