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

Refine type restriction of Math.frexp(BigFloat) #10998

Merged

Conversation

straight-shoota
Copy link
Member

The return type of this overload depended on LibC::SizeT. This patch unifies it to {BigFloat, Int32} on any architecture.

This is technically a breaking change. Restricting the union in the return type restriction further down to one member of the union is technically fine. But the union did not happen in practice, because the actual type was always Int32 or Int64 depending on the architecture.

#10645 (comment)

@straight-shoota straight-shoota added kind:bug A bug in the code. Does not apply to documentation, specs, etc. breaking-change topic:stdlib:numeric labels Jul 23, 2021
@HertzDevil
Copy link
Contributor

On 64-bit systems BigFloats can get large enough to have exponents that don't fit into an Int32, so I'd prefer to_i64 over to_i32:

Math.frexp(2.to_big_f ** 1_000_000_000_000_i64) # => {0.5, 1000000000001}

@beta-ziliani beta-ziliani added this to the 1.2.0 milestone Sep 15, 2021
@straight-shoota straight-shoota merged commit 6d2c877 into crystal-lang:master Sep 21, 2021
@straight-shoota straight-shoota deleted the fix/math-frexp-big_float branch September 21, 2021 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change 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.

3 participants