fenv


1. Checking for Support of Floating-Point Exceptions (FE_ALL_EXCEPT)

#include <fenv.h>
int main() {
  fenv_t env;
  fegetenv(&env);
  if (fegetexceptflag(&env, FE_ALL_EXCEPT) & FE_ALL_EXCEPT) {
    printf("All floating-point exceptions are supported.\n");
  } else {
    printf("Some or all floating-point exceptions are not supported.\n");
  }
  return 0;
}

2. Setting Floating-Point Exceptions (FE_ALL_EXCEPT)

#include <fenv.h>
int main() {
  fenv_t env;
  fegetenv(&env);
  fesetenv(&env);
  if (fegetexceptflag(&env, FE_ALL_EXCEPT) & FE_ALL_EXCEPT) {
    printf("All floating-point exceptions are enabled.\n");
  }
  return 0;
}

3. Clearing Floating-Point Exceptions (FE_ALL_EXCEPT)

4. Getting the Exception Status (FE_ALL_EXCEPT)

5. Raising an Invalid Operation Exception (FE_INVALID)

6. Ignoring Floating-Point Exceptions (FE_NOMASK)

7. Trapping Floating-Point Exceptions (FE_NOTIFY)

8. Setting the Floating-Point Rounding Mode (FE_TONEAREST)

9. Getting the Floating-Point Rounding Mode (FE_TONEAREST)

10. Checking the Current Processor's Floating-Point State (FE_DFL_ENV)

11. Setting the Processor's Floating-Point State (FE_DFL_ENV)

12. Checking for Floating-Point Unit (FE_HARDWARE)

13. Checking for In-Range Support (FE_INEXACT)

14. Checking for Underflow Support (FE_UNDERFLOW)

15. Checking for Overflow Support (FE_OVERFLOW)

16. Checking for Divide-by-Zero Support (FE_DIVBYZERO)

17. Getting the Floating-Point Status Flags

18. Setting the Floating-Point Status Flags

19. Resetting the Floating-Point Status Flags

20. Getting the Floating-Point Control Mode

21. Setting the Floating-Point Control Mode

22. Resetting the Floating-Point Control Mode

23. Getting the Floating-Point Precision Mode

24. Setting the Floating-Point Precision Mode

25. Resetting the Floating-Point Precision Mode

26. Rounding to a Specified Precision

27. Getting the Floating-Point Rounding Direction

28. Setting the Floating-Point Rounding Direction

29. Resetting the Floating-Point Rounding Direction

30. Getting the Floating-Point MXCSR Register

31. Setting the Floating-Point MXCSR Register

32. Resetting the Floating-Point MXCSR Register

33. Checking if the Floating-Point Unit is Busy (FE_BUSY)

34. Clearing the Floating-Point Unit Busy Flag (FE_BUSY)

35. Getting the Floating-Point Status of an FPU Register (FE_STATUS)

36. Setting the Floating-Point Status of an FPU Register (FE_STATUS)

37. Resetting the Floating-Point Status of an FPU Register (FE_STATUS)

38. Getting the Floating-Point Control Mode of an FPU Register (FE_CONTROL)

39. Setting the Floating-Point Control Mode of an FPU Register (FE_CONTROL)

40. Resetting the Floating-Point Control Mode of an FPU Register (FE_CONTROL)

41. Getting the Floating-Point Precision Mode of an FPU Register (FE_PRECISION)

42. Setting the Floating-Point Precision Mode of an FPU Register (FE_PRECISION)

43. Resetting the Floating-Point Precision Mode of an FPU Register (FE_PRECISION)

44. Getting the Floating-Point Rounding Direction of an FPU Register (FE_ROUNDING)

45. Setting the Floating-Point Rounding Direction of an FPU Register (FE_ROUNDING)

46. Resetting the Floating-Point Rounding Direction of an FPU Register (FE_ROUNDING)

47. Getting the Floating-Point MXCSR Register of an FPU Register (FE_MXCSR)

48. Setting the Floating-Point MXCSR Register of an FPU Register (FE_MXCSR)

49. Resetting the Floating-Point MXCSR Register of an FPU Register (FE_MXCSR)

50. Combining and Using Multiple Floating-Point Environment Functions