-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
document rounding behavior of rint/nearbyint for ties #119656
Conversation
(rustbot has picked a reviewer for you, use r? to override) |
I opened llvm/llvm-project#77191 to clarify the docs on the LLVM side. |
/// Returns the nearest integer to an `f32`. Changing the rounding mode is not possible in Rust, | ||
/// so this rounds half-way cases to the number with an even least significant digit. | ||
/// | ||
/// May raise an inexact floating-point exception if the argument is not an integer. |
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.
This exception isn't mentioned in the round_ties_even docs -- is this something we should be guarding against somehow? Is raising an exception UB, or does that just (guaranteed) abort the program? Feels... unhelpful to have a rounding function only allow exactly integer inputs.
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.
This is an FP exception. All it does is set a bit in some register that Rust code is not allowed to read.
One can set up the FP environment to turn these exceptions into traps, but Rust doesn't permit 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.
Sounds good, thanks.
@bors r+ |
…crum document rounding behavior of rint/nearbyint for ties It's not possible to change the rounding mode in Rust, so these intrinsics will always behave like `roundeven`.
…iaskrgr Rollup of 3 pull requests Successful merges: - rust-lang#119654 (bump bootstrap dependencies) - rust-lang#119656 (document rounding behavior of rint/nearbyint for ties) - rust-lang#119657 (Fix typo in docs for slice::split_once, slice::rsplit_once) r? `@ghost` `@rustbot` modify labels: rollup
…mpiler-errors Rollup of 6 pull requests Successful merges: - rust-lang#119252 (rustc_mir_transform: Enforce `rustc::potential_query_instability` lint) - rust-lang#119548 (Use the current target instead of iterating over all targets) - rust-lang#119656 (document rounding behavior of rint/nearbyint for ties) - rust-lang#119657 (Fix typo in docs for slice::split_once, slice::rsplit_once) - rust-lang#119666 (Populate `yield` and `resume` types in MIR body while body is being initialized) - rust-lang#119679 (Ask for rustc version in diagnostic reports, remind users to update their toolchain) r? `@ghost` `@rustbot` modify labels: rollup
…mpiler-errors Rollup of 6 pull requests Successful merges: - rust-lang#119252 (rustc_mir_transform: Enforce `rustc::potential_query_instability` lint) - rust-lang#119548 (Use the current target instead of iterating over all targets) - rust-lang#119656 (document rounding behavior of rint/nearbyint for ties) - rust-lang#119657 (Fix typo in docs for slice::split_once, slice::rsplit_once) - rust-lang#119666 (Populate `yield` and `resume` types in MIR body while body is being initialized) - rust-lang#119679 (Ask for rustc version in diagnostic reports, remind users to update their toolchain) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#119656 - RalfJung:round-docs, r=Mark-Simulacrum document rounding behavior of rint/nearbyint for ties It's not possible to change the rounding mode in Rust, so these intrinsics will always behave like `roundeven`.
It's not possible to change the rounding mode in Rust, so these intrinsics will always behave like
roundeven
.