From 814090921e6c3b6a61b9328f01d7bad475bdeaf6 Mon Sep 17 00:00:00 2001 From: David Monniaux Date: Sat, 13 Apr 2019 18:46:24 +0200 Subject: test for rounding modes --- test/monniaux/math/rounding.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 test/monniaux/math/rounding.c (limited to 'test/monniaux/math/rounding.c') 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 +#include + +#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); +} -- cgit