Skip to content

Commit

Permalink
Change value of num in example for trait method `Float::integer_dec…
Browse files Browse the repository at this point in the history
…ode`
  • Loading branch information
mtilda committed Jun 26, 2024
1 parent c477dfe commit d3935bf
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/float.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1866,15 +1866,15 @@ pub trait Float: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
/// ```
/// 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 = exponent as f32;
///
/// // 1 * 8388608 * 2^(-22) == 2
/// // 1 * 11010048 * 2^(-18) == 42
/// 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 d3935bf

Please sign in to comment.