|
1 | 1 | // FIXME(f16_f128): only tested on platforms that have symbols and aren't buggy
|
2 | 2 | #![cfg(target_has_reliable_f128)]
|
3 | 3 |
|
4 |
| -use std::f128::consts; |
5 |
| - |
6 | 4 | use super::{assert_approx_eq, assert_biteq};
|
7 | 5 |
|
8 | 6 | // Note these tolerances make sense around zero, but not for more extreme exponents.
|
9 | 7 |
|
10 | 8 | /// Default tolerances. Works for values that should be near precise but not exact. Roughly
|
11 | 9 | /// the precision carried by `100 * 100`.
|
| 10 | +#[allow(unused)] |
12 | 11 | const TOL: f128 = 1e-12;
|
13 | 12 |
|
14 | 13 | /// For operations that are near exact, usually not involving math of different
|
15 | 14 | /// signs.
|
| 15 | +#[allow(unused)] |
16 | 16 | const TOL_PRECISE: f128 = 1e-28;
|
17 | 17 |
|
18 | 18 | /// First pattern over the mantissa
|
@@ -44,70 +44,12 @@ fn test_mul_add() {
|
44 | 44 |
|
45 | 45 | #[test]
|
46 | 46 | #[cfg(any(miri, target_has_reliable_f128_math))]
|
47 |
| -fn test_recip() { |
48 |
| - let nan: f128 = f128::NAN; |
49 |
| - let inf: f128 = f128::INFINITY; |
50 |
| - let neg_inf: f128 = f128::NEG_INFINITY; |
51 |
| - assert_biteq!(1.0f128.recip(), 1.0); |
52 |
| - assert_biteq!(2.0f128.recip(), 0.5); |
53 |
| - assert_biteq!((-0.4f128).recip(), -2.5); |
54 |
| - assert_biteq!(0.0f128.recip(), inf); |
| 47 | +fn test_max_recip() { |
55 | 48 | assert_approx_eq!(
|
56 | 49 | f128::MAX.recip(),
|
57 | 50 | 8.40525785778023376565669454330438228902076605e-4933,
|
58 | 51 | 1e-4900
|
59 | 52 | );
|
60 |
| - assert!(nan.recip().is_nan()); |
61 |
| - assert_biteq!(inf.recip(), 0.0); |
62 |
| - assert_biteq!(neg_inf.recip(), -0.0); |
63 |
| -} |
64 |
| - |
65 |
| -#[test] |
66 |
| -#[cfg(not(miri))] |
67 |
| -#[cfg(target_has_reliable_f128_math)] |
68 |
| -fn test_powi() { |
69 |
| - let nan: f128 = f128::NAN; |
70 |
| - let inf: f128 = f128::INFINITY; |
71 |
| - let neg_inf: f128 = f128::NEG_INFINITY; |
72 |
| - assert_biteq!(1.0f128.powi(1), 1.0); |
73 |
| - assert_approx_eq!((-3.1f128).powi(2), 9.6100000000000005506706202140776519387, TOL); |
74 |
| - assert_approx_eq!(5.9f128.powi(-2), 0.028727377190462507313100483690639638451, TOL); |
75 |
| - assert_biteq!(8.3f128.powi(0), 1.0); |
76 |
| - assert!(nan.powi(2).is_nan()); |
77 |
| - assert_biteq!(inf.powi(3), inf); |
78 |
| - assert_biteq!(neg_inf.powi(2), inf); |
79 |
| -} |
80 |
| - |
81 |
| -#[test] |
82 |
| -fn test_to_degrees() { |
83 |
| - let pi: f128 = consts::PI; |
84 |
| - let nan: f128 = f128::NAN; |
85 |
| - let inf: f128 = f128::INFINITY; |
86 |
| - let neg_inf: f128 = f128::NEG_INFINITY; |
87 |
| - assert_biteq!(0.0f128.to_degrees(), 0.0); |
88 |
| - assert_approx_eq!((-5.8f128).to_degrees(), -332.31552117587745090765431723855668471, TOL); |
89 |
| - assert_approx_eq!(pi.to_degrees(), 180.0, TOL); |
90 |
| - assert!(nan.to_degrees().is_nan()); |
91 |
| - assert_biteq!(inf.to_degrees(), inf); |
92 |
| - assert_biteq!(neg_inf.to_degrees(), neg_inf); |
93 |
| - assert_biteq!(1_f128.to_degrees(), 57.2957795130823208767981548141051703); |
94 |
| -} |
95 |
| - |
96 |
| -#[test] |
97 |
| -fn test_to_radians() { |
98 |
| - let pi: f128 = consts::PI; |
99 |
| - let nan: f128 = f128::NAN; |
100 |
| - let inf: f128 = f128::INFINITY; |
101 |
| - let neg_inf: f128 = f128::NEG_INFINITY; |
102 |
| - assert_biteq!(0.0f128.to_radians(), 0.0); |
103 |
| - assert_approx_eq!(154.6f128.to_radians(), 2.6982790235832334267135442069489767804, TOL); |
104 |
| - assert_approx_eq!((-332.31f128).to_radians(), -5.7999036373023566567593094812182763013, TOL); |
105 |
| - // check approx rather than exact because round trip for pi doesn't fall on an exactly |
106 |
| - // representable value (unlike `f32` and `f64`). |
107 |
| - assert_approx_eq!(180.0f128.to_radians(), pi, TOL_PRECISE); |
108 |
| - assert!(nan.to_radians().is_nan()); |
109 |
| - assert_biteq!(inf.to_radians(), inf); |
110 |
| - assert_biteq!(neg_inf.to_radians(), neg_inf); |
111 | 53 | }
|
112 | 54 |
|
113 | 55 | #[test]
|
|
0 commit comments