Sets floating-point environment flags.
#include <fenv.h> void feraiseexcept(int e);
e
Zero or more exceptions to set.
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) { double x = 123.0; double y = 3.0; double result; /* Reset flags before starting the calculation. */ feclearexcept(FE_ALL_EXCEPT); result = x / y; /* Should not set the FE_DIVBYZERO flag. */ if (fetestexcept(FE_DIVBYZERO | FE_INVALID)) printf("Division by zero and invalid operation.\n"); feraiseexcept(FE_DIVBYZERO); if (fetestexcept(FE_DIVBYZERO)) printf("Division by zero.\n"); return 0; } Output: Division by zero.