Skip to content

#fmt handles %f incorrectly when the number needs rounding (truncates instead) #1876

Closed
@bzbarsky

Description

@bzbarsky

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!".

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions