Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 18 Mar 2024 19:50:31 +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-587dxzCYX7@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 #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.

home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-277783-227-587dxzCYX7>