Returns the floating-point environment's current rounding direction.
#include <fenv.h> int fegetround(void);
This facility may not be available on configurations of the EWL that run on platforms that do not have floating-point math capabilities.
#include <fenv.h> #include <stdio.h> #pragma STDC FENV_ACCESS on int main(void) { int direction; double x_up = 0.0; double a = 5.0; double b = 2.0; double c = 3.0; double d = 6.0; double f = 2.5; double g = 0.5; double ubound = 0.0; feclearexcept(FE_ALL_EXCEPT); /* Calculate denominator. */ fesetround(FE_DOWNWARD); x_up = f + g; direction = fegetround(); /* Save the direction. */ fesetround(FE_UPWARD); ubound = (a * b + c * d) / x_up; fesetround(direction); /* Restore original direction. */ printf("(a * b + c * d) / (f + g) = %g\n", ubound); return 0; } Output: 9.3333