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

Make equality between Complex and other numbers exact #14309

Merged
merged 3 commits into from
Feb 21, 2024

Conversation

HertzDevil
Copy link
Contributor

#to_c effectively calls #to_f64, which may lead to precision loss. This PR replaces that with a direct comparison with the real component, relying on the exactness of that #==.

In practice, this only affects comparisons between Complex and the Big* types, since integer-float comparisons are still subject to #14303:

# not affected by this PR
(2.0 ** 64).to_c == UInt64::MAX # => true

@straight-shoota straight-shoota added this to the 1.12.0 milestone Feb 19, 2024
@straight-shoota straight-shoota merged commit 0a2203b into crystal-lang:master Feb 21, 2024
57 checks passed
@HertzDevil HertzDevil deleted the bug/complex-eq-exact branch February 24, 2024 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants