...
However, this code may produce a domain error if x
is negative.
Compliant Solution
Since Because this function has domain errors but no range errors, bounds checking can be used to prevent domain errors:
...
This code may produce a range error if x
has a very large magnitude.
Compliant Solution
Since Because this function has no domain errors but may have range errors, the programmer must detect a range error and act accordingly:
...
However, this code may produce a domain error if x
is negative and y
is not an integer or if x
is 0 and y
is 0. A domain error or range error may occur if x
is 0 and y
is negative, and a range error may occur if the result cannot be represented as a double
.
Compliant Solution
Since Because the pow()
function can produce both domain errors and range errors, the programmer must first check that x
and y
lie within the proper domain, then detect if a range error occurs and act accordingly:
...