| Previous | Next |
| EPIPE | ERANGE |
EDOM
Invalid mathematical input, not merely a large result
EDOM is a domain error: the supplied value is outside the set of inputs for which the mathematical function is defined in the relevant real-valued interface. For example, the Linux log() family treats a negative argument as a domain error and returns NaN; pow() has a domain error when its base is negative and its finite exponent is nonintegral.
It is important not to collapse this into ERANGE. For log(), zero is not a domain error in the same sense: it is a pole error whose mathematical result is negative infinity, and the interface reports ERANGE. The distinction tells you whether to correct the input domain or to handle a valid operation whose result cannot be represented normally.
Checking math failures reliably
- Record the function, all input values, and whether an input was NaN or an infinity; the same symbolic error can correspond to different preconditions for different functions.
- Validate known domain constraints before calling the function when the application has a clear recovery rule.
- When checking library results, clear
errnoand floating-point exception flags before the call; inspect both the return value and the relevant floating-point status afterward. - Be careful with compiler options and optimized math implementations. The documented error-signaling behavior belongs to the function and runtime configuration actually used by the build.
References
Looking for a different code? Search another status or error code.