// Issue #61130
{-1, 1, 1, 0},
{1, 1, -1, 0},
+
+ // Issue #73757
+ {0x1p-1022, -0x1p-1022, 0, Copysign(0, -1)},
+ {Copysign(0, -1), 1, 0, 0},
+ {1, Copysign(0, -1), 0, 0},
}
var sqrt32 = []float32{
bx, by, bz := Float64bits(x), Float64bits(y), Float64bits(z)
// Inf or NaN or zero involved. At most one rounding will occur.
- if x == 0.0 || y == 0.0 || z == 0.0 || bx&uvinf == uvinf || by&uvinf == uvinf {
+ if x == 0.0 || y == 0.0 || bx&uvinf == uvinf || by&uvinf == uvinf {
return x*y + z
}
+ // Handle z == 0.0 separately.
+ // Adding zero usually does not change the original value.
+ // However, there is an exception with negative zero. (e.g. (-0) + (+0) = (+0))
+ // This applies when x * y is negative and underflows.
+ if z == 0.0 {
+ return x * y
+ }
// Handle non-finite z separately. Evaluating x*y+z where
// x and y are finite, but z is infinite, should always result in z.
if bz&uvinf == uvinf {