Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@ protected boolean supportsDecimalCoerce() {

@Override
protected TestRange<Float> randomRangeForSyntheticSourceTest() {
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);
Copy link
Contributor Author

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.

Copy link
Contributor

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.

boolean valuesAdjacent = Math.nextUp(from) > Math.nextDown(to);
var includeFrom = valuesAdjacent || randomBoolean();
var includeTo = valuesAdjacent || randomBoolean();

if (rarely()) {
from = null;
Expand Down