Skip to content

Commit

Permalink
Clarify float rounding direction for signed zero
Browse files Browse the repository at this point in the history
  • Loading branch information
orlp committed Oct 2, 2023
1 parent 8e47113 commit 07e9631
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions library/core/src/primitive_docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1142,10 +1142,9 @@ impl<T: Copy> Copy for (T,) {
/// surprising results upon inspecting the bit patterns,
/// as the same calculations might produce NaNs with different bit patterns.
///
/// When the number resulting from a primitive operation (addition,
/// subtraction, multiplication, or division) on this type is not exactly
/// representable as `f32`, it is rounded according to the roundTiesToEven
/// direction defined in IEEE 754-2008. That means:
/// When a primitive operation (addition, subtraction, multiplication, or
/// division) is performed on this type, the result is rounded according to the
/// roundTiesToEven direction defined in IEEE 754-2008. That means:
///
/// - The result is the representable value closest to the true value, if there
/// is a unique closest representable value.
Expand All @@ -1154,6 +1153,9 @@ impl<T: Copy> Copy for (T,) {
/// - If the true value's magnitude is ≥ `f32::MAX` + 2<sup>(`f32::MAX_EXP` −
/// `f32::MANTISSA_DIGITS` − 1)</sup>, the result is ∞ or −∞ (preserving the
/// true value's sign).
/// - If the result of a sum exactly equals zero, the outcome is +0.0 unless
/// both arguments were negative, then it is -0.0. Subtraction `a - b` is
/// regarded as a sum `a + (-b)`.
///
/// For more information on floating point numbers, see [Wikipedia][wikipedia].
///
Expand Down

0 comments on commit 07e9631

Please sign in to comment.