Skip to content

Commit 043fcc4

Browse files
authored
Rollup merge of #116355 - orlp:signed-zero-rounding-mode, r=thomcc
Clarify float rounding direction for signed zero Closes #116339.
2 parents cebe393 + 07e9631 commit 043fcc4

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

library/core/src/primitive_docs.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -1142,10 +1142,9 @@ impl<T: Copy> Copy for (T,) {
11421142
/// surprising results upon inspecting the bit patterns,
11431143
/// as the same calculations might produce NaNs with different bit patterns.
11441144
///
1145-
/// When the number resulting from a primitive operation (addition,
1146-
/// subtraction, multiplication, or division) on this type is not exactly
1147-
/// representable as `f32`, it is rounded according to the roundTiesToEven
1148-
/// direction defined in IEEE 754-2008. That means:
1145+
/// When a primitive operation (addition, subtraction, multiplication, or
1146+
/// division) is performed on this type, the result is rounded according to the
1147+
/// roundTiesToEven direction defined in IEEE 754-2008. That means:
11491148
///
11501149
/// - The result is the representable value closest to the true value, if there
11511150
/// is a unique closest representable value.
@@ -1154,6 +1153,9 @@ impl<T: Copy> Copy for (T,) {
11541153
/// - If the true value's magnitude is ≥ `f32::MAX` + 2<sup>(`f32::MAX_EXP` −
11551154
/// `f32::MANTISSA_DIGITS` − 1)</sup>, the result is ∞ or −∞ (preserving the
11561155
/// true value's sign).
1156+
/// - If the result of a sum exactly equals zero, the outcome is +0.0 unless
1157+
/// both arguments were negative, then it is -0.0. Subtraction `a - b` is
1158+
/// regarded as a sum `a + (-b)`.
11571159
///
11581160
/// For more information on floating point numbers, see [Wikipedia][wikipedia].
11591161
///

0 commit comments

Comments
 (0)