-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Add f16
formatting and parsing
#127013
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
base: master
Are you sure you want to change the base?
Add f16
formatting and parsing
#127013
Conversation
This comment has been minimized.
This comment has been minimized.
@rustbot label +rla-silenced |
@rustbot label +F-f16_and_f128 |
This will need #127510 |
☔ The latest upstream changes (presumably #127020) made this pull request unmergeable. Please resolve the merge conflicts. |
7c3f9c1
to
f3ebeb3
Compare
Update: I'm really just waiting on #128083 to bump stage0, managing |
☔ The latest upstream changes (presumably #128360) made this pull request unmergeable. Please resolve the merge conflicts. |
2eaa479
to
422c52e
Compare
21ffabc
to
2098f01
Compare
404089f
to
3636530
Compare
6840636
to
bea36a2
Compare
@bors try |
Add `f16` formatting and parsing Use the same algorithms as for `f32` and `f64` to implement `f16` parsing and printing. try-job: aarch64-gnu
This comment was marked as outdated.
This comment was marked as outdated.
This comment has been minimized.
This comment has been minimized.
This comment was marked as outdated.
This comment was marked as outdated.
7d0475a
to
4638679
Compare
@bors try |
Add `f16` formatting and parsing Use the same algorithms as for `f32` and `f64` to implement `f16` parsing and printing. try-job: aarch64-gnu try-job: dist-s390x-linux try-job: x86_64-mingw-1 try-job: x86_64-mingw-2
☀️ Try build successful - checks-actions |
@Mark-Simulacrum the only thing that changed from the original approval should be the addition of the fallback. I double checked with Bjorn and there shouldn’t be any problems with that. @rustbot ready |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me with nit fixed
library/core/src/num/dec2flt/mod.rs
Outdated
// FIXME(f16_f128): A fallback is used when the backend+target does not support f16 well, in order | ||
// to avoid ICEs. | ||
|
||
// After the bootstrap bump this should be: `#[cfg(not(target_has_reliable_f16))` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If true, please write this as a pair of cfg_attrs not a comment - we have some partial automation that can find and replace cfg attrs automatically but comments are near invisible to that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is indeed not correct, the comment is from before the post-bump rebase. Removed.
Use the existing Lemire (decimal -> float) and Dragon / Grisu algorithms (float -> decimal) to add support for `f16`. This allows updating the implementation for `Display` to the expected behavior for `Display` (currently it prints the a hex bitwise representation), matching other floats, and adds a `FromStr` implementation. In order to avoid crashes when compiling with Cranelift or on targets where f16 is not well supported, a fallback is used if `cfg(target_has_reliable_f16)` is not true.
Extend the existing tests for `f32` and `f64` with versions that include `f16`'s new printing and parsing implementations. Co-authored-by: Speedy_Lex <[email protected]>
This requires a fix to the subnormal test to cap the maximum allowed value within the maximum mantissa.
4638679
to
221d7f3
Compare
@bors r=Mark-Simulacrum |
…Simulacrum Add `f16` formatting and parsing Use the same algorithms as for `f32` and `f64` to implement `f16` parsing and printing. try-job: aarch64-gnu try-job: dist-s390x-linux try-job: x86_64-mingw-1 try-job: x86_64-mingw-2
Use the same algorithms as for
f32
andf64
to implementf16
parsing and printing.try-job: aarch64-gnu
try-job: dist-s390x-linux
try-job: x86_64-mingw-1
try-job: x86_64-mingw-2