Skip to content

Commit

Permalink
Fix bug in example for trait method Float::integer_decode
Browse files Browse the repository at this point in the history
  • Loading branch information
mtilda committed Jun 26, 2024
1 parent 7ec3d41 commit c477dfe
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/float.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1872,10 +1872,10 @@ pub trait Float: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
/// 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();
/// let abs_difference = (sign_f * mantissa_f * 2_f32.powf(exponent_f) - num).abs();
///
/// assert!(abs_difference < 1e-10);
/// ```
Expand Down

0 comments on commit c477dfe

Please sign in to comment.