##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# MATH_ERRNO, MATH_ERREXCEPT, math_errhandling

From cppreference.com
< cpp‎ | numeric‎ | math

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.

The following floating-point error conditions are recognized:

| This section is incomplete Reason: needs to be a table

1. Domain error (input argument is outside the range in which the operation is mathematically defined, e.g. std::sqrt(-1), std::log(-1), or std::acos(2)). If `MATH_ERRNO` bit is set, EDOM is assigned to errno. If MATH_ERREXCEPT bit is set, FE_INVALID is raised.
2. Range error (the mathematical result cannot be represented as the object of specified type, e.g. std::atanh(-1), std::log(0.0), or std::lgamma(0.0)). If MATH_ERRNO bit is set, ERANGE is assigned to errno. If MATH_ERREXCEPT bit is set, FE_DIVBYZERO or FE_OVERFLOW is raised.
3. Overflow (the mathematical result is finite, but too big to be represented without extreme roundoff error, e.g. functions such as std::exp with sufficiently large arguments). If MATH_ERRNO bit is set, ERANGE is assigned to errno. If MATH_ERREXCEPT bit is set, FE_OVERFLOW is raised.
4. Underflow (the mathematical result is non-zero, but too small to be represented without extreme roundoff error, e.g. the result is subnormal, as in std::sin(subnormal) or for many other functions with subnormal arguments). If MATH_ERRNO bit is set, ERANGE may be assigned to errno. If MATH_ERREXCEPT bit is set, FE_UNDERFLOW may be raised.

### [edit] Example

| This section is incomplete Reason: no example

### [edit] See also

FE_ALL_EXCEPT FE_DIVBYZERO FE_INEXACT FE_INVALID FE_OVERFLOW FE_UNDERFLOW (C++11) | floating-point exceptions (macro constant) [edit]
errno | macro which expands to POSIX-compatible thread-local error number variable (macro variable) [edit]

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/numeric/math/math_errhandling&oldid=62871"
Categories:

- Todo with reason
- Todo no example