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