Skip to content

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

@HertzDevil HertzDevil added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:numeric labels Feb 19, 2024
@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
@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

Labels

kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:numeric

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants