Rollup merge of #116355 - orlp:signed-zero-rounding-mode, r=thomcc

Clarify float rounding direction for signed zero

Closes https://github.com/rust-lang/rust/issues/116339.
This commit is contained in:
Matthias Krüger 2023-10-03 08:58:50 +02:00 committed by GitHub
commit 043fcc487a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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