...
However, for some functions it is not practical to use bounds checking to prevent all errors. In the above pow
example, the bounds check does not prevent the pow(10., 1e6)
range error. In these cases detection must be used, either in addition to bounds checking or instead of bounds checking.
Anchor | ||||
---|---|---|---|---|
|
acos
...
(x), asin
...
(x)
Noncompliant Code Example
...
Code Block | ||
---|---|---|
| ||
double x; double y; double result; /* Set the value for x and y */ if ( (x == 0.f) && (y == 0.f) ) { /* handle domain error */ } result = atan2(y, x); |
Anchor | ||||
---|---|---|---|---|
|
log
...
(x), log10
...
(x)
Noncompliant Code Example
...
Code Block | ||
---|---|---|
| ||
double x; double y; double result; if (((x == 0.f) && islessequal(y, 0)) || (isless(x, 0))) { /* handle domain and range errors */ } result = pow(x, y); |
Anchor | ||||
---|---|---|---|---|
|
sqrt
...
(x)
Noncompliant Code Example
...