diff options
author | David Monniaux <david.monniaux@univ-grenoble-alpes.fr> | 2019-04-13 18:46:24 +0200 |
---|---|---|
committer | David Monniaux <david.monniaux@univ-grenoble-alpes.fr> | 2019-04-13 18:46:24 +0200 |
commit | 814090921e6c3b6a61b9328f01d7bad475bdeaf6 (patch) | |
tree | b818a32ce8d1d02da41ebb672d227ebfe000c18f | |
parent | 67be67deebe911c6f202338178e53787f17dd76d (diff) | |
download | compcert-kvx-814090921e6c3b6a61b9328f01d7bad475bdeaf6.tar.gz compcert-kvx-814090921e6c3b6a61b9328f01d7bad475bdeaf6.zip |
test for rounding modes
-rw-r--r-- | test/monniaux/math/rounding.c | 20 |
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); +} |