docs: mention round-to-even in precision formatting

This commit is contained in:
Tristan F 2024-02-12 08:20:13 -05:00 committed by GitHub
parent b17491c8f6
commit 730560b982
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -278,6 +278,19 @@
//! Hello, ` 123` has 3 right-aligned characters
//! ```
//!
//! When truncuating these values, Rust uses round-to-even, which may
//! cause concern when formatting for scientific notation. For example,
//!
//! ```
//! print!("{0:.1$e}", 12345, 3);
//! ```
//!
//! Would return:
//!
//! ```text
//! 1.234e4
//! ```
//!
//! ## Localization
//!
//! In some programming languages, the behavior of string formatting functions