random: Randomizer::getFloat(): Fix check for empty open intervals #10185
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The check for invalid parameters for the IntervalBoundary::OpenOpen variant was not correct: If two consecutive doubles are passed as parameters, the resulting interval is empty, resulting in an uint64 underflow in the γ-section implementation.
Instead of checking whether
$min < $max
, we must check that there is at least one more double between$min
and$max
, i.e. it must hold that:Instead of duplicating the comparatively complicated and expensive
nextafter
logic for a rare error case we instead returnNAN
from the γ-section implementation when the parameters result in an empty interval and thus underflow.This allows us to reliably detect this specific error case after the fact, but without modifying the engine state. It also provides reliable error reporting for other internal functions that might use the γ-section implementation.