diff --git a/src/libstd/num/f32.rs b/src/libstd/num/f32.rs index ff80a4e3053..17d412411c0 100644 --- a/src/libstd/num/f32.rs +++ b/src/libstd/num/f32.rs @@ -217,7 +217,7 @@ impl f32 { /// // Values between `0` and `min` are Subnormal. /// assert!(!lower_than_min.is_normal()); /// ``` - /// [subnormal]: http://en.wikipedia.org/wiki/Denormal_number + /// [subnormal]: https://en.wikipedia.org/wiki/Denormal_number #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn is_normal(self) -> bool { num::Float::is_normal(self) } @@ -923,12 +923,12 @@ impl f32 { /// Computes the tangent of a number (in radians). /// /// ``` - /// use std::f64; + /// use std::f32; /// - /// let x = f64::consts::PI/4.0; + /// let x = f32::consts::PI / 4.0; /// let abs_difference = (x.tan() - 1.0).abs(); /// - /// assert!(abs_difference < 1e-10); + /// assert!(abs_difference <= f32::EPSILON); /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] @@ -1052,12 +1052,14 @@ impl f32 { /// number is close to zero. /// /// ``` - /// let x = 7.0f64; + /// use std::f32; /// - /// // e^(ln(7)) - 1 - /// let abs_difference = (x.ln().exp_m1() - 6.0).abs(); + /// let x = 6.0f32; /// - /// assert!(abs_difference < 1e-10); + /// // e^(ln(6)) - 1 + /// let abs_difference = (x.ln().exp_m1() - 5.0).abs(); + /// + /// assert!(abs_difference <= f32::EPSILON); /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] diff --git a/src/libstd/num/f64.rs b/src/libstd/num/f64.rs index b7750317870..70b7706535c 100644 --- a/src/libstd/num/f64.rs +++ b/src/libstd/num/f64.rs @@ -147,23 +147,23 @@ impl f64 { /// [subnormal][subnormal], or `NaN`. /// /// ``` - /// use std::f32; + /// use std::f64; /// - /// let min = f32::MIN_POSITIVE; // 1.17549435e-38f64 - /// let max = f32::MAX; - /// let lower_than_min = 1.0e-40_f32; - /// let zero = 0.0f32; + /// let min = f64::MIN_POSITIVE; // 2.2250738585072014e-308f64 + /// let max = f64::MAX; + /// let lower_than_min = 1.0e-308_f64; + /// let zero = 0.0f64; /// /// assert!(min.is_normal()); /// assert!(max.is_normal()); /// /// assert!(!zero.is_normal()); - /// assert!(!f32::NAN.is_normal()); - /// assert!(!f32::INFINITY.is_normal()); + /// assert!(!f64::NAN.is_normal()); + /// assert!(!f64::INFINITY.is_normal()); /// // Values between `0` and `min` are Subnormal. /// assert!(!lower_than_min.is_normal()); /// ``` - /// [subnormal]: http://en.wikipedia.org/wiki/Denormal_number + /// [subnormal]: https://en.wikipedia.org/wiki/Denormal_number #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn is_normal(self) -> bool { num::Float::is_normal(self) } @@ -655,9 +655,9 @@ impl f64 { /// ``` /// #![feature(float_extras)] /// - /// let x = 1.0f32; + /// let x = 1.0f64; /// - /// let abs_diff = (x.next_after(2.0) - 1.00000011920928955078125_f32).abs(); + /// let abs_diff = (x.next_after(2.0) - 1.0000000000000002220446049250313_f64).abs(); /// /// assert!(abs_diff < 1e-10); /// ``` diff --git a/src/libstd/primitive_docs.rs b/src/libstd/primitive_docs.rs index 11af768c5b9..be9cd6a6888 100644 --- a/src/libstd/primitive_docs.rs +++ b/src/libstd/primitive_docs.rs @@ -490,9 +490,6 @@ mod prim_tuple { } /// /// *[See also the `std::f32` module](f32/index.html).* /// -/// However, please note that examples are shared between the `f64` and `f32` -/// primitive types. So it's normal if you see usage of `f64` in there. -/// mod prim_f32 { } #[doc(primitive = "f64")] @@ -501,9 +498,6 @@ mod prim_f32 { } /// /// *[See also the `std::f64` module](f64/index.html).* /// -/// However, please note that examples are shared between the `f64` and `f32` -/// primitive types. So it's normal if you see usage of `f32` in there. -/// mod prim_f64 { } #[doc(primitive = "i8")]