by Cyphus · 2y ago · 0 comments
I'm somewhat baffled by this statement. If a Go program compared a constant expression float against a runtime computed float, it could have unexpected results, but comparing floats in general is dangerous. I don't see how this language quirk increases that danger in a meaningful way.
That said, for the negatives it comes with it does come with positives as well and I think that makes it worth it.
It's another thing if a language sometimes outputs two and sometimes outputs one depending on the syntax of the request. This is reasonable where that syntax change is not an explicit cast to double precision or single precision, but dangerous if it uses a behind-the-scenes default of arbitrary precision in compiled literals and a default of FP32 in implicitly typed literal assignments.
var d = -0.0
is different than var d = 0.0
d = -d
This IMO crosses the line into "outright bug" territory.