[Bug 277783] libc fma() doesn't not return the correct zero sign
- In reply to: bugzilla-noreply_a_freebsd.org: "[Bug 277783] libc fma() doesn't not return the correct zero sign"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 18 Mar 2024 19:50:31 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=277783
--- Comment #2 from Steve Kargl <kargl@FreeBSD.org> ---
So, I don't loose a reduced version of the code:
#include <math.h>
#include <stdio.h>
int
main(void)
{
volatile double x = 0x1p-500, y = 0x1p-550, z = 0x1p-1000;
double a, b, c, r;
a = x-y;
b = x+y;
c = -z;
r = fma(a, b, c);
/*
* Should print -0 instead of +0.
*/
printf("fma(%+a, %+a, %+a) = %+g\n", a, b, c, r);
return 0;
}
% cc -o z -O3 a.c -lm && ./z
fma(+0x1.ffffffffffff8p-501, +0x1.0000000000004p-500, -0x1p-1000) = +0
% cc -o z -O3 a.c -mfma -lm && ./z
fma(+0x1.ffffffffffff8p-501, +0x1.0000000000004p-500, -0x1p-1000) = -0
--
You are receiving this mail because:
You are the assignee for the bug.