title | description | ms.date | api_name | api_location | api_type | topic_type | f1_keywords | helpviewer_keywords | ms.assetid | |||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
cos, cosf, cosl |
API reference for cos, cosf, and cosl; which calculate the cosine value of a floating-point number. |
08/31/2020 |
|
|
|
|
|
|
ae90435e-6b68-4a47-a81f-be87d5c08f16 |
Calculates the cosine.
double cos( double x );
float cosf( float x );
long double cosl( long double x );
#define cos(X) // Requires C11 or higher
float cos( float x ); // C++ only
long double cos( long double x ); // C++ only
x
Angle in radians.
The cosine of x. If x is greater than or equal to 263, or less than or equal to -263, a loss of significance in the result occurs.
Input | SEH Exception | Matherr Exception |
---|---|---|
± QNAN, IND | none | _DOMAIN |
± INF | INVALID | _DOMAIN |
Because C++ allows overloading, you can call overloads of cos that take and return float
or long double
values. In a C program, unless you're using the <tgmath.h> macro to call this function, cos always takes and returns a double
.
If you use the <tgmath.h> cos()
macro, the type of the argument determines which version of the function is selected. See Type-generic math for details.
By default, this function's global state is scoped to the application. To change this, see Global state in the CRT.
Routine | Required C header | Required C++ header |
---|---|---|
cos, cosh, cosf | <math.h> | <cmath> or <math.h> |
cos() macro | <tgmath.h> |
For additional compatibility information, see Compatibility.
See the example in sin, sinf, sinl.
Floating-Point Support
acos, acosf, acosl
asin, asinf, asinl
atan, atanf, atanl, atan2, atan2f, atan2l
_matherr
sin, sinf, sinl
tan, tanf, tanl
_CIcos