Uh oh!
There was an error while loading. Please reload this page.
document rounding behavior of rint/nearbyint for ties - #119656
Conversation
rustbot
commented
Jan 6, 2024
(rustbot has picked a reviewer for you, use r? to override) |
RalfJung
commented
Jan 6, 2024
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.
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.
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.
Mark-Simulacrum
commented
Jan 6, 2024
@bors r+ |
bors
commented
Jan 6, 2024
…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.