aboutsummaryrefslogtreecommitdiffstats
path: root/test/monniaux/math
diff options
context:
space:
mode:
authorDavid Monniaux <david.monniaux@univ-grenoble-alpes.fr>2019-04-13 18:46:24 +0200
committerDavid Monniaux <david.monniaux@univ-grenoble-alpes.fr>2019-04-13 18:46:24 +0200
commit814090921e6c3b6a61b9328f01d7bad475bdeaf6 (patch)
treeb818a32ce8d1d02da41ebb672d227ebfe000c18f /test/monniaux/math
parent67be67deebe911c6f202338178e53787f17dd76d (diff)
downloadcompcert-kvx-814090921e6c3b6a61b9328f01d7bad475bdeaf6.tar.gz
compcert-kvx-814090921e6c3b6a61b9328f01d7bad475bdeaf6.zip
test for rounding modes
Diffstat (limited to 'test/monniaux/math')
-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);
+}