aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--test/monniaux/math/rounding.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/monniaux/math/rounding.c b/test/monniaux/math/rounding.c
new file mode 100644
index 00000000..4831c3d1
--- /dev/null
+++ b/test/monniaux/math/rounding.c
@@ -0,0 +1,20 @@
+#include <stdio.h>
+#include <fenv.h>
+
+#pragma STDC FENV_ACCESS ON
+
+double inverse(double x) {
+ return 1.0 / x;
+}
+
+int main() {
+ if (fesetround(FE_DOWNWARD)) {
+ printf("fesetround(FE_DOWNWARD) unsuccessful\n");
+ }
+ double low = inverse(3.0);
+ if (fesetround(FE_UPWARD)) {
+ printf("fesetround(FE_UPWARD) unsuccessful\n");
+ }
+ double high = inverse(3.0);
+ printf("%d %a\n", low==high, high-low);
+}