Skip to content

Commit ea3cc4e

Browse files
Szabolcs Nagyjart
authored andcommitted
math: fix fma(x,y,0) when x*y rounds to -0
if x!=0, y!=0, z==0 then fma(x,y,z) == x*y in all rounding modes, while adding z can ruin the sign of 0 if x*y rounds to -0.
1 parent 01267ea commit ea3cc4e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

libc/tinymath/fma.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ double fma(double x, double y, double z)
145145
return x*y + z;
146146
if (nz.e >= ZEROINFNAN) {
147147
if (nz.e > ZEROINFNAN) /* z==0 */
148-
return x*y + z;
148+
return x*y;
149149
return z;
150150
}
151151

0 commit comments

Comments
 (0)