MATH_ERRNO, MATH_ERREXCEPT, math_errhandling
From cppreference.com
Defined in header <cmath>
|
||
#define MATH_ERRNO 1 |
(since C++11) | |
#define MATH_ERREXCEPT 2 |
(since C++11) | |
#define math_errhandling /*implementation defined*/ |
(since C++11) | |
The macro constant math_errhandling
expands to an expression of type int that is either equal to MATH_ERRNO
, or equal to MATH_ERREXCEPT
, or equal to their bitwise OR (MATH_ERRNO | MATH_ERREXCEPT).
The value of math_errhandling
indicates the type of error handling that is performed by the floating-point operators and functions:
Constant | Explanation |
MATH_ERREXCEPT
|
Indicates that floating-point exceptions are used: at least FE_DIVBYZERO, FE_INVALID, and FE_OVERFLOW are defined in <cfenv>. |
MATH_ERRNO
|
Indicates that floating-point operations use the variable errno to report errors. |
If the implementation supports IEEE floating-point arithmetic (IEC 60559), math_errhandling & MATH_ERREXCEPT is required to be non-zero.
The following floating-point error conditions are recognized:
Condition | Explanation | errno | Floating-point exception | Example |
---|---|---|---|---|
Domain error | The argument is outside the range in which the operation is mathematically defined (the description of each function lists the required domain errors) | EDOM | FE_INVALID | std::acos(2) |
Pole error | The mathematical result of the function is exactly infinite or undefined | ERANGE | FE_DIVBYZERO | std::log(0.0), 1.0 / 0.0 |
Range error due to overflow | The mathematical result is finite, but becomes infinite after rounding, or becomes the largest representable finite value after rounding down | ERANGE | FE_OVERFLOW | std::pow( |