FreeBSD Bugzilla – Attachment 249266 Details for
Bug 277783
libc fma() doesn't not return the correct zero sign
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
Example reproducing the fma() zero sign issue
x.c (text/plain), 1.01 KB, created by
Victor Stinner
on 2024-03-18 13:04:09 UTC
(
hide
)
Description:
Example reproducing the fma() zero sign issue
Filename:
MIME Type:
Creator:
Victor Stinner
Created:
2024-03-18 13:04:09 UTC
Size:
1.01 KB
patch
obsolete
>#include <math.h> >#include <string.h> >#include <stdio.h> > >void set_double(double *x, const char *bytes) >{ > memcpy(x, bytes, sizeof(*x)); >} > >int main(int argc, char **argv) >{ > double x = 0; //float.fromhex('0x1p-500') > double y = 0; //float.fromhex('0x1p-550') > double z = 0; //float.fromhex('0x1p-1000') >#if 1 > // condition always true, but trick the compiler, otherwise it will not > // call fma() at runtime, but just compute the result at build time. > if (argc) { > set_double(&x, "\x00\x00\x00\x00\x00\x00\xb0\x20"); > } > else { > x = 123; > } >#else > set_double(&x, "\x00\x00\x00\x00\x00\x00\xb0\x20"); >#endif > set_double(&y, "\x00\x00\x00\x00\x00\x00\x90\x1d"); > set_double(&z, "\x00\x00\x00\x00\x00\x00p\x01"); > > printf("x %g\n", x); > printf("y %g\n", y); > printf("z %g\n", z); > > double a, b, c, r; > a = x-y; > b = x+y; > c = -z; > r = fma(a, b, c); > printf("fma(x-y, x+y, -z):\n"); > printf("fma(%+g, %+g, %+g) = %+g\n", a, b, c, r); > return 0; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 277783
: 249266 |
251421
|
251488
|
251489