nearbyintl.c 377 字节
Newer Older
1 2 3
#include <math.h>
#include <float.h>

R
Rich Felker 已提交
4 5 6 7 8 9 10 11 12
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double nearbyintl(long double x)
{
	return nearbyint(x);
}
#else
#include <fenv.h>
long double nearbyintl(long double x)
{
13 14
#ifdef FE_INEXACT
	int e;
R
Rich Felker 已提交
15

16 17
	e = fetestexcept(FE_INEXACT);
#endif
R
Rich Felker 已提交
18
	x = rintl(x);
19 20 21 22
#ifdef FE_INEXACT
	if (!e)
		feclearexcept(FE_INEXACT);
#endif
R
Rich Felker 已提交
23 24 25
	return x;
}
#endif