| OLD | NEW |
| 1 #include <fenv.h> | 1 #include <fenv.h> |
| 2 #include "libm.h" | 2 #include "libm.h" |
| 3 | 3 |
| 4 #if LDBL_MANT_DIG==64 && LDBL_MAX_EXP==16384 | 4 #if LDBL_MANT_DIG==64 && LDBL_MAX_EXP==16384 |
| 5 /* exact add, assumes exponent_x >= exponent_y */ | 5 /* exact add, assumes exponent_x >= exponent_y */ |
| 6 static void add(long double *hi, long double *lo, long double x, long double y) | 6 static void add(long double *hi, long double *lo, long double x, long double y) |
| 7 { | 7 { |
| 8 long double r; | 8 long double r; |
| 9 | 9 |
| 10 r = x + y; | 10 r = x + y; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 | 72 |
| 73 static int getexp(long double x) | 73 static int getexp(long double x) |
| 74 { | 74 { |
| 75 union ldshape u; | 75 union ldshape u; |
| 76 u.f = x; | 76 u.f = x; |
| 77 return u.i.se & 0x7fff; | 77 return u.i.se & 0x7fff; |
| 78 } | 78 } |
| 79 | 79 |
| 80 double fma(double x, double y, double z) | 80 double fma(double x, double y, double z) |
| 81 { | 81 { |
| 82 » #pragma STDC FENV_ACCESS ON | 82 » PRAGMA_STDC_FENV_ACCESS_ON |
| 83 long double hi, lo1, lo2, xy; | 83 long double hi, lo1, lo2, xy; |
| 84 int round, ez, exy; | 84 int round, ez, exy; |
| 85 | 85 |
| 86 /* handle +-inf,nan */ | 86 /* handle +-inf,nan */ |
| 87 if (!isfinite(x) || !isfinite(y)) | 87 if (!isfinite(x) || !isfinite(y)) |
| 88 return x*y + z; | 88 return x*y + z; |
| 89 if (!isfinite(z)) | 89 if (!isfinite(z)) |
| 90 return z; | 90 return z; |
| 91 /* handle +-0 */ | 91 /* handle +-0 */ |
| 92 if (x == 0.0 || y == 0.0) | 92 if (x == 0.0 || y == 0.0) |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 return ret; | 451 return ret; |
| 452 } | 452 } |
| 453 | 453 |
| 454 adj = add_adjusted(r.lo, xy.lo); | 454 adj = add_adjusted(r.lo, xy.lo); |
| 455 if (spread + ilogb(r.hi) > -1023) | 455 if (spread + ilogb(r.hi) > -1023) |
| 456 return scalbn(r.hi + adj, spread); | 456 return scalbn(r.hi + adj, spread); |
| 457 else | 457 else |
| 458 return add_and_denormalize(r.hi, adj, spread); | 458 return add_and_denormalize(r.hi, adj, spread); |
| 459 } | 459 } |
| 460 #endif | 460 #endif |
| OLD | NEW |