Skip to content

odd issue with #fmt and floats #1388

@erickt

Description

@erickt

I've run into a rather weird error with #fmt and floats:

use std;
import std::io;

fn main() {
    let f = -0.550153;
    let s = #fmt("%f", f);
    io::println(s);
}

Incorrectly prints out 0. But if we instead write:

use std;
import std::io;

fn main() {
    let f = -0.550153;
    let s = #fmt("%f", f);
    io::println(s);
    io::println("before " + s + " after");
}

It prints out:

-0.550152
before -0.550152 after

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions