about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-10-03 08:58:50 +0200
committerGitHub <noreply@github.com>2023-10-03 08:58:50 +0200
commit043fcc487a2fe3c286cbccd87ac29277ba5a4ae1 (patch)
tree73e0df691c281dd5a3795413499d08fcd813658d
parentcebe393a4a19738a927ad84afffbb4015d7e6f06 (diff)
parent07e96314ec1ea2cd28f10224a90f1647e3082515 (diff)
downloadrust-043fcc487a2fe3c286cbccd87ac29277ba5a4ae1.tar.gz
rust-043fcc487a2fe3c286cbccd87ac29277ba5a4ae1.zip
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.
-rw-r--r--library/core/src/primitive_docs.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/library/core/src/primitive_docs.rs b/library/core/src/primitive_docs.rs
index fd5fe5a04f4..380a21b376b 100644
--- a/library/core/src/primitive_docs.rs
+++ b/library/core/src/primitive_docs.rs
@@ -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].
 ///