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/> References: <bug-277783-227@https.bugs.freebsd.org/bugzilla/>
next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D277783 --- 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 =3D -0.5 (gdb) p xy.hi $13 =3D 0.5 (gdb) p xy.lo $14 =3D -3.944304526105059e-31 (gdb) p spread $15 =3D -999 Turns out that ldexp(3.944304526105059e-31, -999) =3D -0x0p+0. So, you have 0.5 - 0.5 - 0. =3D 0. - 0. =3D +0 So, a pessimestic patch is Index: src/s_fma.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- src/s_fma.c (revision 2834) +++ src/s_fma.c (working copy) @@ -267,7 +267,9 @@ */ fesetround(oround); volatile double vzs =3D zs; /* XXX gcc CSE bug workaround */ - return (xy.hi + vzs + ldexp(xy.lo, spread)); + xs =3D ldexp(xy.lo, spread); + xy.hi +=3D vzs; + return (xy.hi =3D=3D 0 ? xs : xy.hi + xs); } if (oround !=3D FE_TONEAREST) { --=20 You are receiving this mail because: You are the assignee for the bug.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-277783-227-1MNRjND0Aq>