File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -1866,16 +1866,16 @@ pub trait Float: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
18661866 /// ```
18671867 /// use num_traits::Float;
18681868 ///
1869- /// let num = 2.0f32 ;
1869+ /// let num = 42_f32 ;
18701870 ///
1871- /// // (8388608 , -22 , 1)
1871+ /// // (11010048 , -18 , 1)
18721872 /// let (mantissa, exponent, sign) = Float::integer_decode(num);
18731873 /// let sign_f = sign as f32;
18741874 /// let mantissa_f = mantissa as f32;
1875- /// let exponent_f = num.powf( exponent as f32) ;
1875+ /// let exponent_f = exponent as f32;
18761876 ///
1877- /// // 1 * 8388608 * 2^(-22 ) == 2
1878- /// let abs_difference = (sign_f * mantissa_f * exponent_f - num).abs();
1877+ /// // 1 * 11010048 * 2^(-18 ) == 42
1878+ /// let abs_difference = (sign_f * mantissa_f * exponent_f.exp2() - num).abs();
18791879 ///
18801880 /// assert!(abs_difference < 1e-10);
18811881 /// ```
You can’t perform that action at this time.
0 commit comments