nearbyintl.c 377 B

12345678910111213141516171819202122232425
  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. int e;
  14. e = fetestexcept(FE_INEXACT);
  15. #endif
  16. x = rintl(x);
  17. #ifdef FE_INEXACT
  18. if (!e)
  19. feclearexcept(FE_INEXACT);
  20. #endif
  21. return x;
  22. }
  23. #endif