Auto merge of #147818 - rperier:unify_and_dedup_max_recip_float_tests… · rust-lang/rust@e517798 (original) (raw)
`@@ -38,6 +38,8 @@ trait TestableFloat: Sized {
`
38
38
`const MUL_ADD_RESULT: Self;
`
39
39
`/// The result of (-12.3).mul_add(-4.5, -6.7)
`
40
40
`const NEG_MUL_ADD_RESULT: Self;
`
``
41
`+
/// Reciprocal of the maximum val
`
``
42
`+
const MAX_RECIP: Self;
`
41
43
`}
`
42
44
``
43
45
`impl TestableFloat for f16 {
`
`@@ -64,6 +66,7 @@ impl TestableFloat for f16 {
`
64
66
`const RAW_MINUS_14_DOT_25: Self = Self::from_bits(0xcb20);
`
65
67
`const MUL_ADD_RESULT: Self = 62.031;
`
66
68
`const NEG_MUL_ADD_RESULT: Self = 48.625;
`
``
69
`+
const MAX_RECIP: Self = 1.526624e-5;
`
67
70
`}
`
68
71
``
69
72
`impl TestableFloat for f32 {
`
`@@ -92,6 +95,7 @@ impl TestableFloat for f32 {
`
92
95
`const RAW_MINUS_14_DOT_25: Self = Self::from_bits(0xc1640000);
`
93
96
`const MUL_ADD_RESULT: Self = 62.05;
`
94
97
`const NEG_MUL_ADD_RESULT: Self = 48.65;
`
``
98
`+
const MAX_RECIP: Self = 2.938736e-39;
`
95
99
`}
`
96
100
``
97
101
`impl TestableFloat for f64 {
`
`@@ -116,6 +120,7 @@ impl TestableFloat for f64 {
`
116
120
`const RAW_MINUS_14_DOT_25: Self = Self::from_bits(0xc02c800000000000);
`
117
121
`const MUL_ADD_RESULT: Self = 62.050000000000004;
`
118
122
`const NEG_MUL_ADD_RESULT: Self = 48.650000000000006;
`
``
123
`+
const MAX_RECIP: Self = 5.562684646268003e-309;
`
119
124
`}
`
120
125
``
121
126
`impl TestableFloat for f128 {
`
`@@ -140,6 +145,7 @@ impl TestableFloat for f128 {
`
140
145
`const RAW_MINUS_14_DOT_25: Self = Self::from_bits(0xc002c800000000000000000000000000);
`
141
146
`const MUL_ADD_RESULT: Self = 62.0500000000000000000000000000000037;
`
142
147
`const NEG_MUL_ADD_RESULT: Self = 48.6500000000000000000000000000000049;
`
``
148
`+
const MAX_RECIP: Self = 8.40525785778023376565669454330438228902076605e-4933;
`
143
149
`}
`
144
150
``
145
151
`/// Determine the tolerance for values of the argument type.
`
`@@ -1425,13 +1431,15 @@ float_test! {
`
1425
1431
`let nan: Float = Float::NAN;
`
1426
1432
`let inf: Float = Float::INFINITY;
`
1427
1433
`let neg_inf: Float = Float::NEG_INFINITY;
`
``
1434
`+
let max: Float = Float::MAX;
`
1428
1435
` assert_biteq!((1.0 as Float).recip(), 1.0);
`
1429
1436
` assert_biteq!((2.0 as Float).recip(), 0.5);
`
1430
1437
` assert_biteq!((-0.4 as Float).recip(), -2.5);
`
1431
1438
` assert_biteq!((0.0 as Float).recip(), inf);
`
1432
1439
` assert!(nan.recip().is_nan());
`
1433
1440
` assert_biteq!(inf.recip(), 0.0);
`
1434
1441
` assert_biteq!(neg_inf.recip(), -0.0);
`
``
1442
`+
assert_biteq!(max.recip(), Float::MAX_RECIP);
`
1435
1443
`}
`
1436
1444
`}
`
1437
1445
``