mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 08:44:35 +00:00
Use rint instead of roundeven
Use rint intrinsic instead of roundeven to impement `round_ties_even`. They do the same thing when rounding mode is default, which Rust assumes. And `rint` has better platform support. Keeps `roundeven` around in `core::intrinsics`, it's doing no harm there.
This commit is contained in:
parent
03c166d389
commit
f8138110bc
@ -295,6 +295,8 @@ fn codegen_float_intrinsic_call<'tcx>(
|
||||
sym::ceilf64 => ("ceil", 1, fx.tcx.types.f64),
|
||||
sym::truncf32 => ("truncf", 1, fx.tcx.types.f32),
|
||||
sym::truncf64 => ("trunc", 1, fx.tcx.types.f64),
|
||||
sym::rintf32 => ("rintf", 1, fx.tcx.types.f32),
|
||||
sym::rintf64 => ("rint", 1, fx.tcx.types.f64),
|
||||
sym::roundf32 => ("roundf", 1, fx.tcx.types.f32),
|
||||
sym::roundf64 => ("round", 1, fx.tcx.types.f64),
|
||||
sym::roundevenf32 => ("roundevenf", 1, fx.tcx.types.f32),
|
||||
|
@ -1588,9 +1588,15 @@ extern "rust-intrinsic" {
|
||||
|
||||
/// Returns the nearest integer to an `f32`. 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)
|
||||
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.
|
||||
///
|
||||
/// The stabilized version of this intrinsic is
|
||||
/// [`f64::round_ties_even`](../../std/primitive.f64.html#method.round_ties_even)
|
||||
pub fn rintf64(x: f64) -> f64;
|
||||
|
||||
/// Returns the nearest integer to an `f32`.
|
||||
@ -1616,16 +1622,13 @@ extern "rust-intrinsic" {
|
||||
/// Returns the nearest integer to an `f32`. Rounds half-way cases to the number
|
||||
/// with an even least significant digit.
|
||||
///
|
||||
/// The stabilized version of this intrinsic is
|
||||
/// [`f32::round_ties_even`](../../std/primitive.f32.html#method.round_ties_even)
|
||||
/// This intrinsic does not have a stable counterpart.
|
||||
#[cfg(not(bootstrap))]
|
||||
pub fn roundevenf32(x: f32) -> f32;
|
||||
|
||||
/// Returns the nearest integer to an `f64`. Rounds half-way cases to the number
|
||||
/// with an even least significant digit.
|
||||
///
|
||||
/// The stabilized version of this intrinsic is
|
||||
/// [`f64::round_ties_even`](../../std/primitive.f64.html#method.round_ties_even)
|
||||
/// This intrinsic does not have a stable counterpart.
|
||||
#[cfg(not(bootstrap))]
|
||||
pub fn roundevenf64(x: f64) -> f64;
|
||||
|
||||
|
@ -119,7 +119,7 @@ impl f32 {
|
||||
#[unstable(feature = "round_ties_even", issue = "96710")]
|
||||
#[inline]
|
||||
pub fn round_ties_even(self) -> f32 {
|
||||
unsafe { intrinsics::roundevenf32(self) }
|
||||
unsafe { intrinsics::rintf32(self) }
|
||||
}
|
||||
|
||||
/// Returns the integer part of `self`.
|
||||
|
@ -119,7 +119,7 @@ impl f64 {
|
||||
#[unstable(feature = "round_ties_even", issue = "96710")]
|
||||
#[inline]
|
||||
pub fn round_ties_even(self) -> f64 {
|
||||
unsafe { intrinsics::roundevenf64(self) }
|
||||
unsafe { intrinsics::rintf64(self) }
|
||||
}
|
||||
|
||||
/// Returns the integer part of `self`.
|
||||
|
Loading…
Reference in New Issue
Block a user