aboutsummaryrefslogtreecommitdiffstats
path: root/test/monniaux/math/rounding.c
blob: 4831c3d19fe2522947167430449837e645ec26b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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);
}