nearbyintl.c 406 B

1234567891011121314151617181920212223242526
  1. #include <math.h>
  2. #include <float.h>
  3. #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
  4. long double nearbyintl(long double x)
  5. {
  6. return nearbyint(x);
  7. }
  8. #else
  9. #include <fenv.h>
  10. long double nearbyintl(long double x)
  11. {
  12. #ifdef FE_INEXACT
  13. #pragma STDC FENV_ACCESS ON
  14. int e;
  15. e = fetestexcept(FE_INEXACT);
  16. #endif
  17. x = rintl(x);
  18. #ifdef FE_INEXACT
  19. if (!e)
  20. feclearexcept(FE_INEXACT);
  21. #endif
  22. return x;
  23. }
  24. #endif