Clarify float rounding direction for signed zero

This commit is contained in:
Orson Peters 2023-10-02 22:05:17 +02:00
parent 8e47113d71
commit 07e96314ec

View File

@ -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.
@ -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].
///