Closed
Description
I found a floating point rounding error in ToStr.
Also, I would expect that ToStr should return exactly the same as Show returns, including all whitespaces.
#[deriving(Show, ToStr)]
struct S {
f : f32,
d : f64,
}
fn main() {
let f : f32 = 1.8;
println!("{}", f); // prints '1.8'
println!("{}", f.to_str()); // prints '1.79999995'
let s = S { f: 1.8, d: 1.8 };
println!("{}", s); // prints 'S { f: 1.8, d: 1.8 }'
println!("{}", s.to_str()); // prints 'S{f: 1.79999995, d: 1.8}'
}
Metadata
Metadata
Assignees
Labels
No labels