Name

cos, cosf, cosl,
- cosine function

Library

libm.lib

Synopsis

  #include <math.h>
  double cos (double x);
  float cosf (float x);
  long double cos (long double x);

Return values

The cos, cosf, and cosl functions return the cosine value.

Detailed description

The cos and cosf functions compute the cosine of x (measured in radians). A large magnitude argument may yield a result with little or no significance. The function cosl is an alias to the function cos.

Examples

#include <math.h>
int main( void )
{
   double pi = 3.1415926535;
   double x, y;
   x = pi / 2;
   y = cos( x );
   printf( "cos( %f ) = %f\n", x, y );
   y = cosf( x );
   printf( "cosf( %f ) = %f\n",x, y );
   y = cosl( x );
   printf( "cosl( %f ) = %f\n",x, y );
}

         

Output

cos ( 1.570796 ) = 0.000000
cosf( 1.570796 ) = 0.000000
cosl( 1.570796 ) = 0.000000

         


See also

acos, asin, atan, atan2, cosh, math, sin, sinh, tan, tanh
The cos function conforms to -isoC.

Feedback

For additional information or queries on this page send feedback

© 2005-2007 Nokia

Top