summaryrefslogtreecommitdiff
path: root/src/math/nearbyintl.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/math/nearbyintl.c')
-rw-r--r--src/math/nearbyintl.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/math/nearbyintl.c b/src/math/nearbyintl.c
new file mode 100644
index 00000000..b58527c8
--- /dev/null
+++ b/src/math/nearbyintl.c
@@ -0,0 +1,18 @@
+#include "libm.h"
+#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)
+{
+ fenv_t e;
+
+ fegetenv(&e);
+ x = rintl(x);
+ fesetenv(&e);
+ return x;
+}
+#endif