Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions library/coretests/tests/floats/f128.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// FIXME(f16_f128): only tested on platforms that have symbols and aren't buggy
#![cfg(target_has_reliable_f128)]

#[cfg(any(miri, target_has_reliable_f128_math))]
use super::assert_approx_eq;
use super::assert_biteq;

// Note these tolerances make sense around zero, but not for more extreme exponents.
Expand All @@ -20,16 +18,6 @@ const TOL_PRECISE: f128 = 1e-28;
// FIXME(f16_f128,miri): many of these have to be disabled since miri does not yet support
// the intrinsics.

#[test]
#[cfg(any(miri, target_has_reliable_f128_math))]
fn test_max_recip() {
assert_approx_eq!(
f128::MAX.recip(),
8.40525785778023376565669454330438228902076605e-4933,
1e-4900
);
}

#[test]
fn test_from() {
assert_biteq!(f128::from(false), 0.0);
Expand Down
8 changes: 1 addition & 7 deletions library/coretests/tests/floats/f16.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// FIXME(f16_f128): only tested on platforms that have symbols and aren't buggy
#![cfg(target_has_reliable_f16)]

use super::{assert_approx_eq, assert_biteq};
use super::assert_biteq;

/// Tolerance for results on the order of 10.0e-2
#[allow(unused)]
Expand All @@ -22,12 +22,6 @@ const TOL_P4: f16 = 10.0;
// FIXME(f16_f128,miri): many of these have to be disabled since miri does not yet support
// the intrinsics.

#[test]
#[cfg(any(miri, target_has_reliable_f16_math))]
fn test_max_recip() {
assert_approx_eq!(f16::MAX.recip(), 1.526624e-5f16, 1e-4);
}

#[test]
fn test_from() {
assert_biteq!(f16::from(false), 0.0);
Expand Down
18 changes: 18 additions & 0 deletions library/coretests/tests/floats/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ trait TestableFloat: Sized {
const MUL_ADD_RESULT: Self;
/// The result of (-12.3).mul_add(-4.5, -6.7)
const NEG_MUL_ADD_RESULT: Self;
/// Reciprocal of the maximum value and an acceptable precision
const MAX_RECIP: Self = Self::APPROX;
const MAX_RECIP_APPROX: Self = Self::APPROX;
}

impl TestableFloat for f16 {
Expand All @@ -64,6 +67,8 @@ impl TestableFloat for f16 {
const RAW_MINUS_14_DOT_25: Self = Self::from_bits(0xcb20);
const MUL_ADD_RESULT: Self = 62.031;
const NEG_MUL_ADD_RESULT: Self = 48.625;
const MAX_RECIP: Self = 1.526624e-5f16;
const MAX_RECIP_APPROX: Self = 1e-4;
}

impl TestableFloat for f32 {
Expand Down Expand Up @@ -140,6 +145,8 @@ impl TestableFloat for f128 {
const RAW_MINUS_14_DOT_25: Self = Self::from_bits(0xc002c800000000000000000000000000);
const MUL_ADD_RESULT: Self = 62.0500000000000000000000000000000037;
const NEG_MUL_ADD_RESULT: Self = 48.6500000000000000000000000000000049;
const MAX_RECIP: Self = 8.40525785778023376565669454330438228902076605e-4933;
const MAX_RECIP_APPROX: Self = 1e-4900;
}

/// Determine the tolerance for values of the argument type.
Expand Down Expand Up @@ -1574,3 +1581,14 @@ float_test! {
assert_biteq!((flt(-3.2)).mul_add(2.4, neg_inf), neg_inf);
}
}

float_test! {
name: max_recip,
attrs: {
f16: #[cfg(any(miri, target_has_reliable_f16_math))],
f128: #[cfg(any(miri, target_has_reliable_f128_math))],
},
test<Float> {
assert_approx_eq!(Float::MAX.recip(), Float::MAX_RECIP, Float::MAX_RECIP_APPROX);
}
}
Loading