Stores a representation of the states of the floating-point exception flags.
#include <fenv.h> void fegetexceptflag(fexcept_t *f, int excepts);
f
A pointer to an exception flag variable.
excepts
Zero or more exceptions to reset.
This function saves the states of floating-point exception flags to memory.
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 = 0.0; double result; fexcept_t flags; /* Reset flags before starting the calculation. */ feclearexcept(FE_ALL_EXCEPT); result = x / y; /* Should set the FE_DIVBYZERO flag. */ fegetexceptflag(&flags, FE_ALL_EXCEPT); if (flags & FE_DIVBYZERO) printf("Division by zero.\n"); if (flags & FE_INEXACT) printf("Inexact value.\n"); return 0; } Output: Division by zero.