mozilla/rust — Issue #1876: #fmt handles %f incorrectly when the number needs rounding (truncates instead)
Author: bzbarsky
Created: 2012-02-21 16:30:18+00:00
State: open

Looks like %f always truncates instead of rounding to the desired precision. For example, this:

use std;
fn main() {
let f = 5.1;
std::io::println(#fmt("hello world %f!", f));
}

prints out "hello world 5.099999!" instead of the expected "hello world 5.100000!".