-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.
Milestone
Description
What version of Go are you using (go version)?
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env)?
linux-amd64
What did you do?
https://go.dev/play/p/KGZMg3ATQtx
package main
import (
"fmt"
"math"
)
var portableFMA = math.FMA
func main() {
fmt.Printf("%g\n", math.FMA(-1, 1, 1))
fmt.Printf("%g\n", portableFMA(-1, 1, 1))
}What did you expect to see?
0
0
What did you see instead?
0
-0
FMA calculates x*y+z. In the portable implementation of FMA if |x*y| is equal to |z| the sign bit of the result is set to the sign bit of x*y. If x*y is negative and z is positive this results in the incorrect result -0.
FMA is an intrinsic on some platforms. This issue only affects the portable implementation (hence the different results when calling FMA directly vs. indirectly).
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.