Skip to content

Commit

Permalink
Rollup merge of #119656 - RalfJung:round-docs, r=Mark-Simulacrum
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
compiler-errors authored Jan 7, 2024
2 parents 20f22ba + 96acaff commit e63a32e
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions library/core/src/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1783,27 +1783,33 @@ extern "rust-intrinsic" {
#[rustc_nounwind]
pub fn truncf64(x: f64) -> f64;

/// Returns the nearest integer to an `f32`. May raise an inexact floating-point exception
/// if the argument is not an integer.
/// 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.
///
/// The stabilized version of this intrinsic is
/// [`f32::round_ties_even`](../../std/primitive.f32.html#method.round_ties_even)
#[rustc_nounwind]
pub fn rintf32(x: f32) -> f32;
/// Returns the nearest integer to an `f64`. May raise an inexact floating-point exception
/// if the argument is not an integer.
/// Returns the nearest integer to an `f64`. 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.
///
/// The stabilized version of this intrinsic is
/// [`f64::round_ties_even`](../../std/primitive.f64.html#method.round_ties_even)
#[rustc_nounwind]
pub fn rintf64(x: f64) -> f64;

/// Returns the nearest integer to an `f32`.
/// 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.
///
/// This intrinsic does not have a stable counterpart.
#[rustc_nounwind]
pub fn nearbyintf32(x: f32) -> f32;
/// Returns the nearest integer to an `f64`.
/// Returns the nearest integer to an `f64`. Changing the rounding mode is not possible in Rust,
/// so this rounds half-way cases to the number with an even least significant digit.
///
/// This intrinsic does not have a stable counterpart.
#[rustc_nounwind]
Expand Down

0 comments on commit e63a32e

Please sign in to comment.