math: portable FMA implementation incorrectly returns -0 in some situations #61130
Labels
NeedsFix
The path to resolution is known, but the work has not been done.
Milestone
What version of Go are you using (
go version
)?8b5fe59
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
What did you expect to see?
What did you see instead?
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 ofx*y
. Ifx*y
is negative andz
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).
The text was updated successfully, but these errors were encountered: