cosl Function

Calculates the trigonometric cosine function of a double precision floating-point value.

Include

<math.h>

Prototype

long double cosl(long double x);

Argument

x
value for which to return the cosine

Return Value

Returns the cosine of x in radians in the ranges of -1 to 1 inclusive.

Remarks

A domain error will occur if x is a NaN or infinity.

Example

#include <math.h>
#include <stdio.h>
#include <errno.h>

int main(void)
{
  long double x,y;

  errno = 0;
  x = -1.0;
  y = cosl(x);
  if (errno)
    perror("Error");
  printf("The cosine of %Lf is %Lf\n", x, y);

  errno = 0;
  x = 0.0;
  y = cosl(x);
  if (errno)
    perror("Error");
  printf("The cosine of %Lf is %Lf\n", x, y);
}

Example Output

The cosine of -1.000000 is 0.540302
The cosine of 0.000000 is 1.000000