Skip to content

Commit c477dfe

Browse files
committed
Fix bug in example for trait method Float::integer_decode
1 parent 7ec3d41 commit c477dfe

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/float.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1872,10 +1872,10 @@ pub trait Float: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
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
///
18771877
/// // 1 * 8388608 * 2^(-22) == 2
1878-
/// let abs_difference = (sign_f * mantissa_f * exponent_f - num).abs();
1878+
/// let abs_difference = (sign_f * mantissa_f * 2_f32.powf(exponent_f) - num).abs();
18791879
///
18801880
/// assert!(abs_difference < 1e-10);
18811881
/// ```

0 commit comments

Comments
 (0)