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

Handle NaNs when comparing BigInt against Float #13293

Merged

Conversation

HertzDevil
Copy link
Contributor

Comparing a BigInt against either Float64::NAN or Float32::NAN will raise SIGFPE. This PR fixes that by making #<=> return nil if that is the case. LibGMP.cmp_d already handles infinities, by the way.

Comparisons between BigInts and BigFloats aren't affected, as GMP's BigFloat does not support NaNs (but MPFR's does).

This is a breaking change because previously those return types weren't nilable.

@HertzDevil HertzDevil changed the title Handle NaNs when comparing BigInt against Float Handle NaNs when comparing BigInt against Float Apr 6, 2023
@straight-shoota straight-shoota added this to the 1.8.0 milestone Apr 6, 2023
@HertzDevil HertzDevil modified the milestones: 1.8.0, 1.9.0 Apr 6, 2023
@straight-shoota straight-shoota merged commit e96f249 into crystal-lang:master Apr 18, 2023
@HertzDevil HertzDevil deleted the bug/bigint-cmp-float branch April 18, 2023 12:21
This pull request was closed.
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