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