History log of /PHP-8.3/ext/random/tests/03_randomizer/methods/getFloat_extreme_range.phpt (Results 1 – 1 of 1)
Revision Date Author Comments
# 582b724c 13-Oct-2023 Tim Düsterhus

random: Fix γ-section implementation for Randomizer::getFloat() (#12402)

The reference implementation of the "Drawing Random Floating-Point Numbers from
an Interval" paper contains two m

random: Fix γ-section implementation for Randomizer::getFloat() (#12402)

The reference implementation of the "Drawing Random Floating-Point Numbers from
an Interval" paper contains two mistakes that will result in erroneous values
being returned under certain circumstances:

- For large values of `g` the multiplication of `k * g` might overflow to
infinity.
- The value of `ceilint()` might exceed 2^53, possibly leading to a rounding
error when promoting `k` to double within the multiplication of `k * g`.

This commit updates the implementation based on Prof. Goualard suggestions
after reaching out to him. It will correctly handle inputs larger than 2^-1020
in absolute values. This limitation will be documented and those inputs
possibly be rejected in a follow-up commit depending on performance concerns.

show more ...