diff options
| author | Tristan F <LeoDog896@hotmail.com> | 2024-02-12 08:20:13 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-12 08:20:13 -0500 |
| commit | 730560b982006c35f811a5de53fe8e1fa422c024 (patch) | |
| tree | f3aaa0d8a53c379256b6f6aa53930b358a0e1346 | |
| parent | b17491c8f6d555386104dfd82004c01bfef09c95 (diff) | |
| download | rust-730560b982006c35f811a5de53fe8e1fa422c024.tar.gz rust-730560b982006c35f811a5de53fe8e1fa422c024.zip | |
docs: mention round-to-even in precision formatting
| -rw-r--r-- | library/alloc/src/fmt.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/library/alloc/src/fmt.rs b/library/alloc/src/fmt.rs index fce2585cbf5..acff026b91b 100644 --- a/library/alloc/src/fmt.rs +++ b/library/alloc/src/fmt.rs @@ -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 |
