They evaluate constant expressions exactly at compile time, then convert to float.
Yes. The behaviour is quite odd and unexpected. It seems they have different rules for when to apply the constant version of floating math than what constitutes actual compile time evaluation.
const a float64 = 0.1;
const b float64 = 0.2;
const x float64 = 0.1 + 0.2; // Const evaluation, "rational" math
const y float64 = a + b; // Const evaluation, IEEE-754 math
fmt.Println(x == y) // false ??!?
This seems quite a horrible approach.EDIT: Or how about this one:
const x float64 = 0;
fmt.Println(x + 0.1 + 0.2 == 0.1 + 0.2 + x ); // false!
fmt.Println(x + 0.1 + 0.2 == x + (0.1 + 0.2) ); // false!