fexcept_t - Linux
Overview
fexcept_t
is a data type that represents the floating-point exception mask. This mask controls the default floating-point exception behavior, indicating which exceptions should raise a signal or error. It is used in conjunction with fenv.h
functions to manipulate floating-point environment settings.
Syntax
typedef unsigned int fexcept_t;
Options/Flags
None.
Examples
Enable invalid operation exception:
fexcept_t mask;
fegetenv(&mask);
mask |= FE_INVALID;
fesetenv(&mask);
Disable all exceptions:
fesetenv((fexcept_t)0);
Check if division by zero exception is enabled:
fexcept_t mask;
fegetenv(&mask);
if (mask & FE_DIVBYZERO)
// Exception is enabled
Common Issues
- Ensure that the floating-point exceptions are enabled before attempting to catch them.
- Use
feraiseexcept
to manually raise floating-point exceptions.
Integration
fexcept_t
is often used with fpu_control_t
to control both floating-point environment and rounding mode settings.
Related Commands
fenv
fesetenv
fegetenv
feupdateenv