-
Notifications
You must be signed in to change notification settings - Fork 25.6k
from needs to less than to in float range #128329
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
from needs to less than to in float range #128329
Conversation
When testing float range, the from and to values are generated then it is decided whether or not to include the bounds within the range. If the values are not included in the range, the min value is calculated as the next higher float value than from and to as the next lower float value. If from and to are immediately adjacent to each other, and bounds are not included, the lower end of the range will be larger than the upper
|
Fixes #128200 |
|
Pinging @elastic/es-storage-engine (Team:StorageEngine) |
| var includeFrom = randomBoolean(); | ||
| Float from = (float) randomDoubleBetween(-Float.MAX_VALUE, Float.MAX_VALUE - Math.ulp(Float.MAX_VALUE), true); | ||
| var includeTo = randomBoolean(); | ||
| Float to = (float) randomDoubleBetween(from + Math.ulp(from), Float.MAX_VALUE, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like it might be cleaner to set the lower bound for to to something like from + 2 * Math.ulp(from), but I'm not sure this is correct. If Math.ulp(to) is larger than Math.ulp(from), then it might be possible for nextUp(from) to be larger than nextDown(to) even is the lower bound used to compute to is increased. That said, I'd be a bit surprised if it's possible for Math.ulp(to) >= 2 * Math.ulp(from). But I don't know enough about floating point math to be sure, so I picked the easier way that I'm sure works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that would work but i also think we don't need this level of precision here.
lkts
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
When testing float range, the from and to values are generated then it is decided whether or not to include the bounds within the range. If the values are not included in the range, the min value is calculated as the next higher float value than from and to as the next lower float value. If from and to are immediately adjacent to each other, and bounds are not included, the lower end of the range will be larger than the upper.