Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Unified Diff: fusl/src/math/nearbyint.c

Issue 1573973002: Add a "fork" of musl as //fusl. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « fusl/src/math/nanl.c ('k') | fusl/src/math/nearbyintf.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fusl/src/math/nearbyint.c
diff --git a/fusl/src/math/nearbyint.c b/fusl/src/math/nearbyint.c
new file mode 100644
index 0000000000000000000000000000000000000000..f4e8aac4f0118d7d48d1d6a8e4af0fec048ee62a
--- /dev/null
+++ b/fusl/src/math/nearbyint.c
@@ -0,0 +1,20 @@
+#include <fenv.h>
+#include <math.h>
+
+/* nearbyint is the same as rint, but it must not raise the inexact exception */
+
+double nearbyint(double x)
+{
+#ifdef FE_INEXACT
+ #pragma STDC FENV_ACCESS ON
+ int e;
+
+ e = fetestexcept(FE_INEXACT);
+#endif
+ x = rint(x);
+#ifdef FE_INEXACT
+ if (!e)
+ feclearexcept(FE_INEXACT);
+#endif
+ return x;
+}
« no previous file with comments | « fusl/src/math/nanl.c ('k') | fusl/src/math/nearbyintf.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698