Skip to content

Commit 985e87e

Browse files
authored
docs: mention round-to-even in precision formatting
1 parent 0a062ec commit 985e87e

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Diff for: alloc/src/fmt.rs

+13
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,19 @@
278278
//! Hello, ` 123` has 3 right-aligned characters
279279
//! ```
280280
//!
281+
//! When truncuating these values, Rust uses round-to-even, which may
282+
//! cause concern when formatting for scientific notation. For example,
283+
//!
284+
//! ```
285+
//! print!("{0:.1$e}", 12345, 3);
286+
//! ```
287+
//!
288+
//! Would return:
289+
//!
290+
//! ```text
291+
//! 1.234e4
292+
//! ```
293+
//!
281294
//! ## Localization
282295
//!
283296
//! In some programming languages, the behavior of string formatting functions

0 commit comments

Comments
 (0)