Skip to content

Commit 6fdb8d8

Browse files
Update signed fmt/-0f32 docs
"semantic equivalence" is too strong a phrasing here, which is why actually explaining what kind of circumstances might produce a -0 was chosen instead.
1 parent 74db93e commit 6fdb8d8

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

library/alloc/src/fmt.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,8 @@
157157
//!
158158
//! * `+` - This is intended for numeric types and indicates that the sign
159159
//! should always be printed. Positive signs are never printed by
160-
//! default, and the negative sign is only printed by default for the
161-
//! `Signed` trait. This flag indicates that the correct sign (`+` or `-`)
162-
//! should always be printed.
160+
//! default, and the negative sign is only printed by default for signed values.
161+
//! This flag indicates that the correct sign (`+` or `-`) should always be printed.
163162
//! * `-` - Currently not used
164163
//! * `#` - This flag indicates that the "alternate" form of printing should
165164
//! be used. The alternate forms are:

library/std/src/primitive_docs.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -805,10 +805,12 @@ mod prim_tuple {}
805805
/// often discard insignificant digits: `println!("{}", 1.0f32 / 5.0f32)` will
806806
/// print `0.2`.
807807
///
808-
/// Additionally, `f32` can represent a couple of special values:
808+
/// Additionally, `f32` can represent some special values:
809809
///
810-
/// - `-0`: this is just due to how floats are encoded. It is semantically
811-
/// equivalent to `0` and `-0.0 == 0.0` results in `true`.
810+
/// - `-0`: this value exists due to how floats are encoded. -0 == 0 is true, but for other
811+
/// operations they are not equal and the difference can be useful to certain algorithms.
812+
/// For example, operations on negative numbers that underflow to 0 will usually generate -0
813+
/// instead of +0.
812814
/// - [∞](#associatedconstant.INFINITY) and
813815
/// [−∞](#associatedconstant.NEG_INFINITY): these result from calculations
814816
/// like `1.0 / 0.0`.

0 commit comments

Comments
 (0)