xref: /aosp_15_r20/external/musl/src/math/nearbyintf.c (revision c9945492fdd68bbe62686c5b452b4dc1be3f8453)
1 #include <fenv.h>
2 #include <math.h>
3 
nearbyintf(float x)4 float nearbyintf(float x)
5 {
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