Closed
Description
I tried this code:
println!("{:.0}", 10.5f64);
I expected to see this happen: It prints 11
Instead, this happened: It prints 10
As far as I am able to find 10.5 has a perfect (lossless) representation in f64-space so it does not seem to be because of floating point error to me.
If I put in 9.5 instead it does work as expected (it prints 10), which is weird because that also has a perfect representation as f64. Is it applying a round_ties_even() kind of logic? If it is then I would expect this to be documented e.g. under https://doc.rust-lang.org/std/fmt/#precision
Meta
I've been using rust playground, rust version 1.70.0