FreeBSD Bugzilla – Attachment 251421 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]
Test code that shows results compared to MPFR
test2.c (text/plain), 1.35 KB, created by
Steve Kargl
on 2024-06-12 19:00:39 UTC
(
hide
)
Description:
Test code that shows results compared to MPFR
Filename:
MIME Type:
Creator:
Steve Kargl
Created:
2024-06-12 19:00:39 UTC
Size:
1.35 KB
patch
obsolete
>#include <fenv.h> >#include <math.h> >#include "mpfr.h" >#include <stdio.h> > >void >test_dbl(double xf, double yf, double zf) >{ > double rf, rr; > mpfr_t rm, xm, ym, zm; > > mpfr_inits2(53, rm, xm, ym, zm, NULL); > > mpfr_set_d(xm, xf, MPFR_RNDN); > mpfr_set_d(ym, yf, MPFR_RNDN); > mpfr_set_d(zm, zf, MPFR_RNDN); > > printf( "dble (x,y,z): % la % la % la\n", xf, yf, zf); > mpfr_printf("mpfr (x,y,z): % Ra % Ra % Ra\n", xm, ym, zm); > > fesetround(FE_TONEAREST); > rf = fma(xf, yf, zf); > mpfr_fma(rm, xm, ym, zm, MPFR_RNDN); > rr = mpfr_get_d(rm, MPFR_RNDN); > printf("RNDN: % la % la\n", rr, rf); > > fesetround(FE_UPWARD); > rf = fma(xf, yf, zf); > mpfr_fma(rm, xm, ym, zm, MPFR_RNDU); > rr = mpfr_get_d(rm, MPFR_RNDU); > printf("RNDU: % la % la\n", rr, rf); > > fesetround(FE_DOWNWARD); > rf = fma(xf, yf, zf); > mpfr_fma(rm, xm, ym, zm, MPFR_RNDD); > rr = mpfr_get_d(rm, MPFR_RNDD); > mpfr_printf("RNDD: % la % la\n", rr, rf); > > fesetround(FE_TOWARDZERO); > rf = fma(xf, yf, zf); > mpfr_fma(rm, xm, ym, zm, MPFR_RNDZ); > rr = mpfr_get_d(rm, MPFR_RNDZ); > printf("RNDZ: % la % la\n\n", rr, rf); > >} > >int >main(void) >{ > double x = 0x1p-500, y = 0x1p-550, z = 0x1p-1000; > double a, b, c; > > a = x - y; > b = x + y; > c = -z; > > test_dbl(-1., 1., 1.); > test_dbl( 1., -1., 1.); > test_dbl(-1., -1., -1.); > > test_dbl(a, b, c); > > 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