remove no-longer-needed abs_private
This commit is contained in:
parent
7d7c0541b9
commit
2d3c08a022
5 changed files with 17 additions and 51 deletions
|
@ -13,7 +13,7 @@ macro_rules! impl_general_format {
|
|||
($($t:ident)*) => {
|
||||
$(impl GeneralFormat for $t {
|
||||
fn already_rounded_value_should_use_exponential(&self) -> bool {
|
||||
let abs = $t::abs_private(*self);
|
||||
let abs = $t::abs(*self);
|
||||
(abs != 0.0 && abs < 1e-4) || abs >= 1e+16
|
||||
}
|
||||
})*
|
||||
|
|
|
@ -284,17 +284,6 @@ impl f128 {
|
|||
self != self
|
||||
}
|
||||
|
||||
// FIXME(#50145): `abs` is publicly unavailable in core due to
|
||||
// concerns about portability, so this implementation is for
|
||||
// private use internally.
|
||||
#[inline]
|
||||
pub(crate) const fn abs_private(self) -> f128 {
|
||||
// SAFETY: This transmutation is fine just like in `to_bits`/`from_bits`.
|
||||
unsafe {
|
||||
mem::transmute::<u128, f128>(mem::transmute::<f128, u128>(self) & !Self::SIGN_MASK)
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns `true` if this value is positive infinity or negative infinity, and
|
||||
/// `false` otherwise.
|
||||
///
|
||||
|
@ -344,10 +333,11 @@ impl f128 {
|
|||
#[inline]
|
||||
#[must_use]
|
||||
#[unstable(feature = "f128", issue = "116909")]
|
||||
#[rustc_allow_const_fn_unstable(const_float_methods)] // for `abs`
|
||||
pub const fn is_finite(self) -> bool {
|
||||
// There's no need to handle NaN separately: if self is NaN,
|
||||
// the comparison is not true, exactly as desired.
|
||||
self.abs_private() < Self::INFINITY
|
||||
self.abs() < Self::INFINITY
|
||||
}
|
||||
|
||||
/// Returns `true` if the number is [subnormal].
|
||||
|
@ -835,8 +825,8 @@ impl f128 {
|
|||
const HI: f128 = f128::MAX / 2.;
|
||||
|
||||
let (a, b) = (self, other);
|
||||
let abs_a = a.abs_private();
|
||||
let abs_b = b.abs_private();
|
||||
let abs_a = a.abs();
|
||||
let abs_b = b.abs();
|
||||
|
||||
if abs_a <= HI && abs_b <= HI {
|
||||
// Overflow is impossible
|
||||
|
|
|
@ -278,15 +278,6 @@ impl f16 {
|
|||
self != self
|
||||
}
|
||||
|
||||
// FIXMxE(#50145): `abs` is publicly unavailable in core due to
|
||||
// concerns about portability, so this implementation is for
|
||||
// private use internally.
|
||||
#[inline]
|
||||
pub(crate) const fn abs_private(self) -> f16 {
|
||||
// SAFETY: This transmutation is fine just like in `to_bits`/`from_bits`.
|
||||
unsafe { mem::transmute::<u16, f16>(mem::transmute::<f16, u16>(self) & !Self::SIGN_MASK) }
|
||||
}
|
||||
|
||||
/// Returns `true` if this value is positive infinity or negative infinity, and
|
||||
/// `false` otherwise.
|
||||
///
|
||||
|
@ -334,10 +325,11 @@ impl f16 {
|
|||
#[inline]
|
||||
#[must_use]
|
||||
#[unstable(feature = "f16", issue = "116909")]
|
||||
#[rustc_allow_const_fn_unstable(const_float_methods)] // for `abs`
|
||||
pub const fn is_finite(self) -> bool {
|
||||
// There's no need to handle NaN separately: if self is NaN,
|
||||
// the comparison is not true, exactly as desired.
|
||||
self.abs_private() < Self::INFINITY
|
||||
self.abs() < Self::INFINITY
|
||||
}
|
||||
|
||||
/// Returns `true` if the number is [subnormal].
|
||||
|
@ -820,8 +812,8 @@ impl f16 {
|
|||
const HI: f16 = f16::MAX / 2.;
|
||||
|
||||
let (a, b) = (self, other);
|
||||
let abs_a = a.abs_private();
|
||||
let abs_b = b.abs_private();
|
||||
let abs_a = a.abs();
|
||||
let abs_b = b.abs();
|
||||
|
||||
if abs_a <= HI && abs_b <= HI {
|
||||
// Overflow is impossible
|
||||
|
|
|
@ -524,15 +524,6 @@ impl f32 {
|
|||
self != self
|
||||
}
|
||||
|
||||
// FIXME(#50145): `abs` is publicly unavailable in core due to
|
||||
// concerns about portability, so this implementation is for
|
||||
// private use internally.
|
||||
#[inline]
|
||||
pub(crate) const fn abs_private(self) -> f32 {
|
||||
// SAFETY: This transmutation is fine just like in `to_bits`/`from_bits`.
|
||||
unsafe { mem::transmute::<u32, f32>(mem::transmute::<f32, u32>(self) & !Self::SIGN_MASK) }
|
||||
}
|
||||
|
||||
/// Returns `true` if this value is positive infinity or negative infinity, and
|
||||
/// `false` otherwise.
|
||||
///
|
||||
|
@ -577,10 +568,11 @@ impl f32 {
|
|||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_stable(feature = "const_float_classify", since = "1.83.0")]
|
||||
#[inline]
|
||||
#[rustc_allow_const_fn_unstable(const_float_methods)] // for `abs`
|
||||
pub const fn is_finite(self) -> bool {
|
||||
// There's no need to handle NaN separately: if self is NaN,
|
||||
// the comparison is not true, exactly as desired.
|
||||
self.abs_private() < Self::INFINITY
|
||||
self.abs() < Self::INFINITY
|
||||
}
|
||||
|
||||
/// Returns `true` if the number is [subnormal].
|
||||
|
@ -1020,8 +1012,8 @@ impl f32 {
|
|||
const HI: f32 = f32::MAX / 2.;
|
||||
|
||||
let (a, b) = (self, other);
|
||||
let abs_a = a.abs_private();
|
||||
let abs_b = b.abs_private();
|
||||
let abs_a = a.abs();
|
||||
let abs_b = b.abs();
|
||||
|
||||
if abs_a <= HI && abs_b <= HI {
|
||||
// Overflow is impossible
|
||||
|
|
|
@ -523,15 +523,6 @@ impl f64 {
|
|||
self != self
|
||||
}
|
||||
|
||||
// FIXME(#50145): `abs` is publicly unavailable in core due to
|
||||
// concerns about portability, so this implementation is for
|
||||
// private use internally.
|
||||
#[inline]
|
||||
pub(crate) const fn abs_private(self) -> f64 {
|
||||
// SAFETY: This transmutation is fine just like in `to_bits`/`from_bits`.
|
||||
unsafe { mem::transmute::<u64, f64>(mem::transmute::<f64, u64>(self) & !Self::SIGN_MASK) }
|
||||
}
|
||||
|
||||
/// Returns `true` if this value is positive infinity or negative infinity, and
|
||||
/// `false` otherwise.
|
||||
///
|
||||
|
@ -576,10 +567,11 @@ impl f64 {
|
|||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_stable(feature = "const_float_classify", since = "1.83.0")]
|
||||
#[inline]
|
||||
#[rustc_allow_const_fn_unstable(const_float_methods)] // for `abs`
|
||||
pub const fn is_finite(self) -> bool {
|
||||
// There's no need to handle NaN separately: if self is NaN,
|
||||
// the comparison is not true, exactly as desired.
|
||||
self.abs_private() < Self::INFINITY
|
||||
self.abs() < Self::INFINITY
|
||||
}
|
||||
|
||||
/// Returns `true` if the number is [subnormal].
|
||||
|
@ -1023,8 +1015,8 @@ impl f64 {
|
|||
const HI: f64 = f64::MAX / 2.;
|
||||
|
||||
let (a, b) = (self, other);
|
||||
let abs_a = a.abs_private();
|
||||
let abs_b = b.abs_private();
|
||||
let abs_a = a.abs();
|
||||
let abs_b = b.abs();
|
||||
|
||||
if abs_a <= HI && abs_b <= HI {
|
||||
// Overflow is impossible
|
||||
|
|
Loading…
Add table
Reference in a new issue