Skip to content

Commit 773bccb

Browse files
Relax some float tests.
1 parent 96279bc commit 773bccb

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

library/std/src/num/f32.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ impl f32 {
479479
/// // log5(5) - 1 == 0
480480
/// let abs_difference = (five.log(5.0) - 1.0).abs();
481481
///
482-
/// assert!(abs_difference <= 1e-6);
482+
/// assert!(abs_difference <= 1e-7);
483483
/// ```
484484
///
485485
/// Non-positive values:
@@ -1125,7 +1125,7 @@ impl f32 {
11251125
///
11261126
/// let abs_difference = (f - e).abs();
11271127
///
1128-
/// assert!(abs_difference <= 1e-4);
1128+
/// assert!(abs_difference <= 1e-5);
11291129
/// ```
11301130
#[doc(alias = "arctanh")]
11311131
#[rustc_allow_incoherent_impl]
@@ -1153,7 +1153,7 @@ impl f32 {
11531153
///
11541154
/// let abs_difference = (x.gamma() - 24.0).abs();
11551155
///
1156-
/// assert!(abs_difference <= 1e-4);
1156+
/// assert!(abs_difference <= 1e-5);
11571157
/// ```
11581158
#[rustc_allow_incoherent_impl]
11591159
#[must_use = "method returns a new number and does not mutate the original value"]

library/std/src/num/f64.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1248,7 +1248,7 @@ impl f64 {
12481248
/// let one = x.erf() + x.erfc();
12491249
/// let abs_difference = (one - 1.0).abs();
12501250
///
1251-
/// assert!(abs_difference <= 1e-10);
1251+
/// assert!(abs_difference <= f64::EPSILON);
12521252
/// ```
12531253
#[rustc_allow_incoherent_impl]
12541254
#[must_use = "method returns a new number and does not mutate the original value"]

library/std/tests/floats/f32.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,10 @@ fn test_gamma() {
196196
assert_approx_eq!(1.0f32.gamma(), 1.0f32);
197197
assert_approx_eq!(2.0f32.gamma(), 1.0f32);
198198
assert_approx_eq!(3.0f32.gamma(), 2.0f32);
199-
assert_approx_eq!(4.0f32.gamma(), 6.0f32, APPROX_DELTA);
199+
assert_approx_eq!(4.0f32.gamma(), 6.0f32);
200200
assert_approx_eq!(5.0f32.gamma(), 24.0f32, APPROX_DELTA);
201201
assert_approx_eq!(0.5f32.gamma(), consts::PI.sqrt());
202-
assert_approx_eq!((-0.5f32).gamma(), -2.0 * consts::PI.sqrt(), APPROX_DELTA);
202+
assert_approx_eq!((-0.5f32).gamma(), -2.0 * consts::PI.sqrt());
203203
assert_eq!(0.0f32.gamma(), f32::INFINITY);
204204
assert_eq!((-0.0f32).gamma(), f32::NEG_INFINITY);
205205
assert!((-1.0f32).gamma().is_nan());

0 commit comments

Comments
 (0)