-
Notifications
You must be signed in to change notification settings - Fork 717
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Randomizer::getFloat() unexpected results in extreme edge cases #3339
Comments
Thank you for the report. Underflow is intentionally left unhandled in the γ-section algorithm used by
The behavior of As mentioned in php/php-src#12402, I intended to document this limitation, but regretfully did not yet get around to it. I'm moving this issue to the documentation repository. |
Sorry for the delay in response. As Tim has already explained, this appears to be a documentation issue. nit: the main cause of my delayed response was my health condition, OPLL, for which I underwent a surgical procedure. I will be able to work more vigorously from now on. Stay tuned. Thanks to @TimWolla for his proactive maintenance in my absence. Thank you. |
Description
While playing around with
Random\Randomizer::getFloat()
I noticed that it does return unexpected results in some extreme edge cases.The following code:
Resulted in this output:
These are all cases where only a single float value is possible to be drawn, but the results are consistently wrong and up to two values apart from the correct result.
Slightly larger ranges also seem to be affected by this. In the following example the floats 1.0E-323 and 1.5E-323 get skipped but the floats 3.5E-323 and 4.0E-323 get included even though they are outside the boundary.
For reference here are the HEX representations (64bit big endian) of the used floats:
PHP Version
PHP 8.3.6
Operating System
macOS 14.4.1 (23E224)
The text was updated successfully, but these errors were encountered: