diff --git a/pkg/geo/geo.go b/pkg/geo/geo.go index c3c6227b2be8..c59dff50abd9 100644 --- a/pkg/geo/geo.go +++ b/pkg/geo/geo.go @@ -756,9 +756,11 @@ func IsLinearRingCCW(linearRing *geom.LinearRing) bool { b := smallest c := linearRing.Coord(nextIdx) - areaSign := a.X()*b.Y() - a.Y()*b.X() + - a.Y()*c.X() - a.X()*c.Y() + - b.X()*c.Y() - c.X()*b.Y() + // Explicitly use float64 conversion to disable "fused multiply and add" (FMA) to force + // identical behavior on all platforms. See https://golang.org/ref/spec#Floating_point_operators + areaSign := float64(a.X()*b.Y()) - float64(a.Y()*b.X()) + // nolint:unconvert + float64(a.Y()*c.X()) - float64(a.X()*c.Y()) + // nolint:unconvert + float64(b.X()*c.Y()) - float64(c.X()*b.Y()) // nolint:unconvert // Note having an area sign of 0 means it is a flat polygon, which is invalid. return areaSign > 0 }