nearbyintf.c 250 B

123456789101112131415161718
  1. #include <fenv.h>
  2. #include <math.h>
  3. float nearbyintf(float x)
  4. {
  5. #ifdef FE_INEXACT
  6. #pragma STDC FENV_ACCESS ON
  7. int e;
  8. e = fetestexcept(FE_INEXACT);
  9. #endif
  10. x = rintf(x);
  11. #ifdef FE_INEXACT
  12. if (!e)
  13. feclearexcept(FE_INEXACT);
  14. #endif
  15. return x;
  16. }