| OLD | NEW |
| 1 #include <fenv.h> | 1 #include <fenv.h> |
| 2 #include <math.h> | 2 #include <math.h> |
| 3 #include "libm.h" | 3 #include "libm.h" |
| 4 | 4 |
| 5 /* nearbyint is the same as rint, but it must not raise the inexact exception */ | 5 /* nearbyint is the same as rint, but it must not raise the inexact exception */ |
| 6 | 6 |
| 7 double nearbyint(double x) | 7 double nearbyint(double x) { |
| 8 { | |
| 9 #ifdef FE_INEXACT | 8 #ifdef FE_INEXACT |
| 10 » PRAGMA_STDC_FENV_ACCESS_ON | 9 PRAGMA_STDC_FENV_ACCESS_ON |
| 11 » int e; | 10 int e; |
| 12 | 11 |
| 13 » e = fetestexcept(FE_INEXACT); | 12 e = fetestexcept(FE_INEXACT); |
| 14 #endif | 13 #endif |
| 15 » x = rint(x); | 14 x = rint(x); |
| 16 #ifdef FE_INEXACT | 15 #ifdef FE_INEXACT |
| 17 » if (!e) | 16 if (!e) |
| 18 » » feclearexcept(FE_INEXACT); | 17 feclearexcept(FE_INEXACT); |
| 19 #endif | 18 #endif |
| 20 » return x; | 19 return x; |
| 21 } | 20 } |
| OLD | NEW |