Date: Mon, 18 Mar 2024 21:06:29 +0000 From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 277783] libc fma() doesn't not return the correct zero sign Message-ID: <bug-277783-227-1MNRjND0Aq@https.bugs.freebsd.org/bugzilla/> In-Reply-To: <bug-277783-227@https.bugs.freebsd.org/bugzilla/>
index | next in thread | previous in thread | raw e-mail
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=277783 --- Comment #4 from Steve Kargl <kargl@FreeBSD.org> --- Ok, with the given input to fma, one arrives at line 271 return (xy.hi + vzs + ldexp(xy.lo, spread)); (gdb) p vzs $12 = -0.5 (gdb) p xy.hi $13 = 0.5 (gdb) p xy.lo $14 = -3.944304526105059e-31 (gdb) p spread $15 = -999 Turns out that ldexp(3.944304526105059e-31, -999) = -0x0p+0. So, you have 0.5 - 0.5 - 0. = 0. - 0. = +0 So, a pessimestic patch is Index: src/s_fma.c =================================================================== --- src/s_fma.c (revision 2834) +++ src/s_fma.c (working copy) @@ -267,7 +267,9 @@ */ fesetround(oround); volatile double vzs = zs; /* XXX gcc CSE bug workaround */ - return (xy.hi + vzs + ldexp(xy.lo, spread)); + xs = ldexp(xy.lo, spread); + xy.hi += vzs; + return (xy.hi == 0 ? xs : xy.hi + xs); } if (oround != FE_TONEAREST) { -- You are receiving this mail because: You are the assignee for the bug.home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-277783-227-1MNRjND0Aq>
