Why does 0.1 + 0.2 = 0.30000000000000004?

Why does 0.1 + 0.2 = 0.30000000000000004?

Julia Evans

@b0rk this reminds me of rounding numbers in JavaScript. Needing to Math.Round(3.5) I’d expect it to be 4, but you have to multiply by 100 and divide by 100. On paper it’s the same, but float numbers are fun. This actually helps explain this kid of situation now!

Math.round(total * 100) / 100