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