cos, cosl

From Appmethod Topics
Jump to: navigation, search

Go Up to math.h Index


Header File

math.h

Category

Math Routines, Inline Routines

Prototype

double cos(double x);

long double cosl(long double x);

Description

Calculates the cosine of a value.

cos computes the cosine of the input value. The angle is specified in radians.

cosl is the long double version; it takes a long double argument and returns a long double result.

Return Value

cos of a real argument returns a value in the range -1 to 1. Error handling for these functions can be modified through _matherr (or _matherrl).

Example

#include <stdio.h>
#include <math.h>
int main(void)
{
   double result;
   double x = 0.5;
   result = cos(x);
   printf("The cosine of %lf is %lf\n", x, result);
   return 0;
}

Portability

POSIX Win32 ANSI C ANSI C++

cos

+

+

+

+

cosl

+

+

+