Skip to content
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

Improve Irrational vs BigFloat comparisons #29196

Closed
wants to merge 1 commit into from

Conversation

simonbyrne
Copy link
Contributor

This creates a fast path via Float64, and falls back on extended precision only when necessary. It also adds a loop to deal with potential edge cases.

This creates a fast path via Float64, and falls back on extended precision only when necessary. It also adds a loop to deal with potential edge cases.
@simonbyrne simonbyrne added the domain:bignums BigInt and BigFloat label Sep 14, 2018
elseif cmp(x, Float64(y, RoundUp)) > 0
return +1
else
for prec in Iterators.countfrom(precision(x), 32)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems dangerous, since if someone defines an "irrational" constant that is actually rational it will never terminate.

How about just something for prec in (precision(x), max(precision(x), precision(BigFloat)) + 32) and return 0 if both of these report equality.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I agree: that would only occur if (a) you define an irrational as a rational value, and (b) compare it to that same rational. I'm not really sure.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #26550 for why some AbstractIrrational subtypes may define rational values.

@giordano giordano deleted the sb/irrational-bigfloat branch December 27, 2022 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:bignums BigInt and BigFloat
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants