Rollup merge of #120967 - LeoDog896:master, r=cuviper

docs: mention round-to-even in precision formatting

_Note_: Not quite sure exactly how to format this documentation.

Mentions round-to-even usage in precision formatting. (should this also be mentioned in `f64::round`?)

From https://github.com/rust-lang/rust/issues/70336
This commit is contained in:
Matthias Krüger 2024-02-13 06:27:38 +01:00 committed by GitHub
commit 134de26337
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -278,6 +278,22 @@
//! Hello, ` 123` has 3 right-aligned characters
//! ```
//!
//! When truncating these values, Rust uses [round half-to-even](https://en.wikipedia.org/wiki/Rounding#Rounding_half_to_even),
//! which is the default rounding mode in IEEE 754.
//! For example,
//!
//! ```
//! print!("{0:.1$e}", 12345, 3);
//! print!("{0:.1$e}", 12355, 3);
//! ```
//!
//! Would return:
//!
//! ```text
//! 1.234e4
//! 1.236e4
//! ```
//!
//! ## Localization
//!
//! In some programming languages, the behavior of string formatting functions