...
An example of a domain error is the square root of a negative number, such as sqrt(-1.0), which has no meaning in real arithmetic. SimilarlyOn the other hand, ten raised to the one-millionth power, pow(10., 1e6), likely cannot be represented in an implementation's floating point representation and consequently constitutes a range error.
...
| Wiki Markup |
|---|
The following table lists standard mathematical functions, along with any checks that should be performed on their domain, and indicates if they also throw range errors, as reported by \[ISO/IEC 9899:1999\]. If a function has a specific domain checks over which it is defined, one should check its input values, and if a function throws range errors, one should detect if a range error occurs. The standard math functions not on this table, such as {{atan()}} have no domain restrictions and do not throw range errors. |
...
Range Checking
Range errors can cannot usually not be prevented, so the most reliable way to handle range errors is to detect when they have occurred and act accordingly.
...
| Anchor | ||||
|---|---|---|---|---|
|
cosh(x), sinh(x)
Noncompliant Code Example
...
(Range Errors)
This The following noncompliant code example determines the hyperbolic cosine of x.
| Code Block | ||
|---|---|---|
| ||
double x; double result; result = cosh(x); |
However, this This code may produce a range error if x has a very large magnitude.
...
| Anchor | ||||
|---|---|---|---|---|
|
pow(x, y)
Noncompliant Code Example
The following noncompliant code raises x to the power of y.
...
Risk Assessment
Failure to properly verify arguments supplied to prevent or detect domain and range errors in math functions may result in unexpected results.
...