Floating point imprecision
fn main() {
let a = 0.1;
let b = 0.2;
let c = a + b;
println!("{c}");
println!("{}", c == 3.0);
}
0.30000000000000004
false
Press ← or → to navigate between chapters
Press S or / to search in the book
Press ? to show this help
Press Esc to hide this help
fn main() {
let a = 0.1;
let b = 0.2;
let c = a + b;
println!("{c}");
println!("{}", c == 3.0);
}
0.30000000000000004
false