graydon/rust — Issue #1388: odd issue with #fmt and floats
Author: erickt
Created: 2011-12-27 04:15:28+00:00
State: open

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