Skip to content

Commit

Permalink
Unrolled build for rust-lang#120967
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#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 rust-lang#70336
  • Loading branch information
rust-timer authored Feb 13, 2024
2 parents 09d73fa + 0f53e72 commit ee1d4f0
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions library/alloc/src/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ee1d4f0

Please sign in to comment.