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

Implement ldexp and use it in ratio_to_f64 #104

Merged
merged 3 commits into from
Jun 23, 2022

Conversation

MattX
Copy link
Contributor

@MattX MattX commented Apr 12, 2022

This eliminates errors where we attempt a multiplication by 2^-x, but that 2^-x underflows. (#91).

This is based on the code in #94.

The ldexp implementation strategy is mostly to extract the exponent, modify it, then reinsert it. To avoid dealing with subnormal numbers at the bit level, we shift any subnormal numbers into normal range before that operation.

Fixes #91.

cuviper and others added 3 commits March 9, 2021 21:57
This eliminates errors where we attempt a multiplication
by 2^-x, but that 2^-x underflows.

The `ldexp` implementation strategy is mostly to extract
the exponent, modify it, then reinsert it. To avoid
dealing with subnormal numbers at the bit level, we
shift any subnormal numbers into normal range before
that operation. This causes no loss of precision.
@MattX MattX force-pushed the to_f64-underflow branch from 60c34c8 to bc1e050 Compare April 12, 2022 21:02
@cuviper
Copy link
Member

cuviper commented Jun 23, 2022

Thanks, and especially the test coverage of ldexp looks great!

bors r+

@bors
Copy link
Contributor

bors bot commented Jun 23, 2022

@bors bors bot merged commit 06d9f21 into rust-num:master Jun 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Conversion to f64 is lossy for tiny floats
2 participants