about summary refs log tree commit diff
path: root/src/math/nearbyintf.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/math/nearbyintf.c')
-rw-r--r--src/math/nearbyintf.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/math/nearbyintf.c b/src/math/nearbyintf.c
new file mode 100644
index 00000000..e4bdb26c
--- /dev/null
+++ b/src/math/nearbyintf.c
@@ -0,0 +1,11 @@
+#include <fenv.h>
+#include "libm.h"
+
+float nearbyintf(float x) {
+	fenv_t e;
+
+	fegetenv(&e);
+	x = rintf(x);
+	fesetenv(&e);
+	return x;
+}