Skip to content

Commit 86bb950

Browse files
change doc-tests to increase EPSILON to make the tests pass
1 parent aa2f5fa commit 86bb950

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

library/std/src/f32.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ impl f32 {
303303
/// ```
304304
/// let x = 2.0_f32;
305305
/// let abs_difference = (x.powi(2) - (x * x)).abs();
306-
/// assert!(abs_difference <= f32::EPSILON);
306+
/// assert!(abs_difference <= 8.0 * f32::EPSILON);
307307
///
308308
/// assert_eq!(f32::powi(f32::NAN, 0), 1.0);
309309
/// ```
@@ -327,7 +327,7 @@ impl f32 {
327327
/// ```
328328
/// let x = 2.0_f32;
329329
/// let abs_difference = (x.powf(2.0) - (x * x)).abs();
330-
/// assert!(abs_difference <= f32::EPSILON);
330+
/// assert!(abs_difference <= 8.0 * f32::EPSILON);
331331
///
332332
/// assert_eq!(f32::powf(1.0, f32::NAN), 1.0);
333333
/// assert_eq!(f32::powf(f32::NAN, 0.0), 1.0);
@@ -387,7 +387,7 @@ impl f32 {
387387
/// // ln(e) - 1 == 0
388388
/// let abs_difference = (e.ln() - 1.0).abs();
389389
///
390-
/// assert!(abs_difference <= f32::EPSILON);
390+
/// assert!(abs_difference <= 4.0 * f32::EPSILON);
391391
/// ```
392392
#[rustc_allow_incoherent_impl]
393393
#[must_use = "method returns a new number and does not mutate the original value"]
@@ -412,7 +412,7 @@ impl f32 {
412412
/// // 2^2 - 4 == 0
413413
/// let abs_difference = (f.exp2() - 4.0).abs();
414414
///
415-
/// assert!(abs_difference <= f32::EPSILON);
415+
/// assert!(abs_difference <= 8.0 * f32::EPSILON);
416416
/// ```
417417
#[rustc_allow_incoherent_impl]
418418
#[must_use = "method returns a new number and does not mutate the original value"]
@@ -439,7 +439,7 @@ impl f32 {
439439
/// // ln(e) - 1 == 0
440440
/// let abs_difference = (e.ln() - 1.0).abs();
441441
///
442-
/// assert!(abs_difference <= f32::EPSILON);
442+
/// assert!(abs_difference <= 4.0 * f32::EPSILON);
443443
/// ```
444444
#[rustc_allow_incoherent_impl]
445445
#[must_use = "method returns a new number and does not mutate the original value"]
@@ -468,7 +468,7 @@ impl f32 {
468468
/// // log5(5) - 1 == 0
469469
/// let abs_difference = (five.log(5.0) - 1.0).abs();
470470
///
471-
/// assert!(abs_difference <= f32::EPSILON);
471+
/// assert!(abs_difference <= 4.0 * f32::EPSILON);
472472
/// ```
473473
#[rustc_allow_incoherent_impl]
474474
#[must_use = "method returns a new number and does not mutate the original value"]
@@ -493,7 +493,7 @@ impl f32 {
493493
/// // log2(2) - 1 == 0
494494
/// let abs_difference = (two.log2() - 1.0).abs();
495495
///
496-
/// assert!(abs_difference <= f32::EPSILON);
496+
/// assert!(abs_difference <= 4.0 * f32::EPSILON);
497497
/// ```
498498
#[rustc_allow_incoherent_impl]
499499
#[must_use = "method returns a new number and does not mutate the original value"]
@@ -518,7 +518,7 @@ impl f32 {
518518
/// // log10(10) - 1 == 0
519519
/// let abs_difference = (ten.log10() - 1.0).abs();
520520
///
521-
/// assert!(abs_difference <= f32::EPSILON);
521+
/// assert!(abs_difference <= 4.0 * f32::EPSILON);
522522
/// ```
523523
#[rustc_allow_incoherent_impl]
524524
#[must_use = "method returns a new number and does not mutate the original value"]
@@ -618,7 +618,7 @@ impl f32 {
618618
/// // sqrt(x^2 + y^2)
619619
/// let abs_difference = (x.hypot(y) - (x.powi(2) + y.powi(2)).sqrt()).abs();
620620
///
621-
/// assert!(abs_difference <= f32::EPSILON);
621+
/// assert!(abs_difference <= 4.0 * f32::EPSILON);
622622
/// ```
623623
#[rustc_allow_incoherent_impl]
624624
#[must_use = "method returns a new number and does not mutate the original value"]
@@ -642,7 +642,7 @@ impl f32 {
642642
///
643643
/// let abs_difference = (x.sin() - 1.0).abs();
644644
///
645-
/// assert!(abs_difference <= f32::EPSILON);
645+
/// assert!(abs_difference <= 4.0 * f32::EPSILON);
646646
/// ```
647647
#[rustc_allow_incoherent_impl]
648648
#[must_use = "method returns a new number and does not mutate the original value"]
@@ -666,7 +666,7 @@ impl f32 {
666666
///
667667
/// let abs_difference = (x.cos() - 1.0).abs();
668668
///
669-
/// assert!(abs_difference <= f32::EPSILON);
669+
/// assert!(abs_difference <= 4.0 * f32::EPSILON);
670670
/// ```
671671
#[rustc_allow_incoherent_impl]
672672
#[must_use = "method returns a new number and does not mutate the original value"]
@@ -750,7 +750,7 @@ impl f32 {
750750
/// // acos(cos(pi/4))
751751
/// let abs_difference = (f.cos().acos() - std::f32::consts::FRAC_PI_4).abs();
752752
///
753-
/// assert!(abs_difference <= f32::EPSILON);
753+
/// assert!(abs_difference <= 4.0 * f32::EPSILON);
754754
/// ```
755755
#[doc(alias = "arccos")]
756756
#[rustc_allow_incoherent_impl]
@@ -850,8 +850,8 @@ impl f32 {
850850
/// let abs_difference_0 = (f.0 - x.sin()).abs();
851851
/// let abs_difference_1 = (f.1 - x.cos()).abs();
852852
///
853-
/// assert!(abs_difference_0 <= f32::EPSILON);
854-
/// assert!(abs_difference_1 <= f32::EPSILON);
853+
/// assert!(abs_difference_0 <= 4.0 * f32::EPSILON);
854+
/// assert!(abs_difference_1 <= 4.0 * f32::EPSILON);
855855
/// ```
856856
#[doc(alias = "sincos")]
857857
#[rustc_allow_incoherent_impl]
@@ -1025,7 +1025,7 @@ impl f32 {
10251025
///
10261026
/// let abs_difference = (f - x).abs();
10271027
///
1028-
/// assert!(abs_difference <= f32::EPSILON);
1028+
/// assert!(abs_difference <= 4.0 * f32::EPSILON);
10291029
/// ```
10301030
#[doc(alias = "arcsinh")]
10311031
#[rustc_allow_incoherent_impl]
@@ -1053,7 +1053,7 @@ impl f32 {
10531053
///
10541054
/// let abs_difference = (f - x).abs();
10551055
///
1056-
/// assert!(abs_difference <= f32::EPSILON);
1056+
/// assert!(abs_difference <= 4.0 * f32::EPSILON);
10571057
/// ```
10581058
#[doc(alias = "arccosh")]
10591059
#[rustc_allow_incoherent_impl]

library/std/src/f64.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ impl f64 {
303303
/// ```
304304
/// let x = 2.0_f64;
305305
/// let abs_difference = (x.powi(2) - (x * x)).abs();
306-
/// assert!(abs_difference <= f64::EPSILON);
306+
/// assert!(abs_difference <= 8.0 * f64::EPSILON);
307307
///
308308
/// assert_eq!(f64::powi(f64::NAN, 0), 1.0);
309309
/// ```
@@ -327,7 +327,7 @@ impl f64 {
327327
/// ```
328328
/// let x = 2.0_f64;
329329
/// let abs_difference = (x.powf(2.0) - (x * x)).abs();
330-
/// assert!(abs_difference <= f64::EPSILON);
330+
/// assert!(abs_difference <= 8.0 * f64::EPSILON);
331331
///
332332
/// assert_eq!(f64::powf(1.0, f64::NAN), 1.0);
333333
/// assert_eq!(f64::powf(f64::NAN, 0.0), 1.0);

0 commit comments

Comments
 (0)