diff --git a/src/float.rs b/src/float.rs index d0d21a5..4124e92 100644 --- a/src/float.rs +++ b/src/float.rs @@ -1866,16 +1866,16 @@ pub trait Float: Num + Copy + NumCast + PartialOrd + Neg { /// ``` /// use num_traits::Float; /// - /// let num = 2.0f32; + /// let num = 42_f32; /// - /// // (8388608, -22, 1) + /// // (11010048, -18, 1) /// let (mantissa, exponent, sign) = Float::integer_decode(num); /// let sign_f = sign as f32; /// let mantissa_f = mantissa as f32; - /// let exponent_f = num.powf(exponent as f32); + /// let exponent_f = exponent as f32; /// - /// // 1 * 8388608 * 2^(-22) == 2 - /// let abs_difference = (sign_f * mantissa_f * exponent_f - num).abs(); + /// // 1 * 11010048 * 2^(-18) == 42 + /// let abs_difference = (sign_f * mantissa_f * exponent_f.exp2() - num).abs(); /// /// assert!(abs_difference < 1e-10); /// ```