Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Edited by sciSpider v2.4 (sch jbop) (X_X)@==(Q_Q)@

...

Anchor
ArcTrig
ArcTrig

acos(error), asin(error)

...

Noncompliant Code Example

The following non-compliant noncompliant code computes the arc cosine of the variable x

...

Anchor
ArcTan
ArcTan

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
bgColor#ccccff
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
Log

log(error), log10(error)

...

Noncompliant Code Example

The following non-compliant noncompliant code determines the natural logarithm of x.

...

Anchor
Power
Power

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
bgColor#ffcccc
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
Sqrt

sqrt(error)

...

Noncompliant Code Example

The following non-compliant noncompliant code determines the square root of x

...