...
Anchor | ||||
---|---|---|---|---|
|
acos, asin
...
Noncompliant Code Example
The following non-compliant noncompliant code computes the arc cosine of the variable x
...
Anchor | ||||
---|---|---|---|---|
|
atan2(y, x)
...
Noncompliant Code Example
The following non-compliant noncompliant code computes the arc tangent of the two variables x
and y
.
...
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, log10
...
Noncompliant Code Example
The following non-compliant noncompliant code determines the natural logarithm of x
.
...
Anchor | ||||
---|---|---|---|---|
|
pow(x, y)
...
Noncompliant Code Example
The following non-compliant noncompliant code raises x
to the power of y
.
...
However, this code may produce a domain error if x
is negative and y
is not an integer, or if x
is zero and y
is zero. A domain error or range error may occur if x
is zero and y
is negative, and a range error may occur if the result cannot be represented as a double
.
...
Noncompliant Code Example
This code only performs bounds checking on x
and y
. It prevents domain errors and some range errors, but does not prevent range errors where the result cannot be represented as a double
(see the Error Checking and Detection section below regarding ways to mitigate the effects of a range error).
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
...
Noncompliant Code Example
The following non-compliant noncompliant code determines the square root of x
...