File tree Expand file tree Collapse file tree 3 files changed +30
-2
lines changed Expand file tree Collapse file tree 3 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -143,8 +143,10 @@ macro_rules! from_str_float_impl {
143143 /// # Return value
144144 ///
145145 /// `Err(ParseFloatError)` if the string did not represent a valid
146- /// number. Otherwise, `Ok(n)` where `n` is the floating-point
147- /// number represented by `src`.
146+ /// number. Otherwise, `Ok(n)` where `n` is the closest
147+ /// representable floating-point number to the number represented
148+ /// by `src` (following the same rules for rounding as for the
149+ /// results of primitive operations).
148150 #[ inline]
149151 fn from_str( src: & str ) -> Result <Self , ParseFloatError > {
150152 dec2flt( src)
Original file line number Diff line number Diff line change @@ -994,6 +994,19 @@ mod prim_tuple {}
994994/// surprising results upon inspecting the bit patterns,
995995/// as the same calculations might produce NaNs with different bit patterns.
996996///
997+ /// When the number resulting from a primitive operation (addition,
998+ /// subtraction, multiplication, or division) on this type is not exactly
999+ /// representable as `f32`, it is rounded according to the roundTiesToEven
1000+ /// direction defined in IEEE 754-2008. That means:
1001+ ///
1002+ /// - The result is the representable value closest to the true value, if there
1003+ /// is a unique closest representable value.
1004+ /// - If the true value is exactly half-way between two representable values,
1005+ /// the result is the one with an even least-significant binary digit.
1006+ /// - If the true value's magnitude is ≥ `f32::MAX` + 2<sup>(`f32::MAX_EXP` −
1007+ /// `f32::MANTISSA_DIGITS` − 1)</sup>, the result is ∞ or −∞ (preserving the
1008+ /// true value's sign).
1009+ ///
9971010/// For more information on floating point numbers, see [Wikipedia][wikipedia].
9981011///
9991012/// *[See also the `std::f32::consts` module](crate::f32::consts).*
Original file line number Diff line number Diff line change @@ -994,6 +994,19 @@ mod prim_tuple {}
994994/// surprising results upon inspecting the bit patterns,
995995/// as the same calculations might produce NaNs with different bit patterns.
996996///
997+ /// When the number resulting from a primitive operation (addition,
998+ /// subtraction, multiplication, or division) on this type is not exactly
999+ /// representable as `f32`, it is rounded according to the roundTiesToEven
1000+ /// direction defined in IEEE 754-2008. That means:
1001+ ///
1002+ /// - The result is the representable value closest to the true value, if there
1003+ /// is a unique closest representable value.
1004+ /// - If the true value is exactly half-way between two representable values,
1005+ /// the result is the one with an even least-significant binary digit.
1006+ /// - If the true value's magnitude is ≥ `f32::MAX` + 2<sup>(`f32::MAX_EXP` −
1007+ /// `f32::MANTISSA_DIGITS` − 1)</sup>, the result is ∞ or −∞ (preserving the
1008+ /// true value's sign).
1009+ ///
9971010/// For more information on floating point numbers, see [Wikipedia][wikipedia].
9981011///
9991012/// *[See also the `std::f32::consts` module](crate::f32::consts).*
You can’t perform that action at this time.
0 commit comments