summaryrefslogtreecommitdiff
path: root/lib/libm/nearbyintf.c
blob: 224af0f6cc52bdf7cd8385d13d731774b1c1a1c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22


#include "bits/fenv.h" // for FE_INEXACT

#include <fenv.h> // for feclearexcept, fetestexcept
#include <math.h> // for nearbyintf, rintf

float nearbyintf(float x)
{
#ifdef FE_INEXACT
#pragma STDC FENV_ACCESS ON
	int e;

	e = fetestexcept(FE_INEXACT);
#endif
	x = rintf(x);
#ifdef FE_INEXACT
	if (!e)
		feclearexcept(FE_INEXACT);
#endif
	return x;
}