Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.
The latest version of this topic can be found at cos, cosf, cosl, cosh, coshf, coshl.
Calculates the cosine (cos, cosf, or cosl), or hyperbolic cosine (cosh, coshf, or coshl).
Syntax
double cos(
double x
);
float cos(
float x
); // C++ only
long double cos(
long double x
); // C++ only
float cosf(
float x
);
long double cosl(
long double x
);
double cosh(
double x
);
float cosh(
float x
); // C++ only
long double cosh(
long double x
); // C++ only
float coshf(
float x
);
long double coshl(
long double x
);
Parameters
x
Angle in radians.
Return Value
The cosine or hyperbolic 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 of a call to cos, cosf, or cosl occurs.
By default, if the result is too large in a cosh, coshf, or coshl call, the function returns HUGE_VAL and sets errno to ERANGE.
| Input | SEH Exception | Matherr Exception |
|---|---|---|
± QNAN,IND |
none | _DOMAIN |
± ∞ (cosf, cos, cosl) |
INVALID |
_DOMAIN |
x ≥ 7.104760e+002 (cosh, coshf, coshl) |
INEXACT+OVERFLOW |
OVERFLOW |
Remarks
Because C++ allows overloading, you can call overloads of cos and cosh that take and return float or long double values. In a C program, cos and cosh always take and return a double.
Requirements
| Routine | Required header |
|---|---|
cos, cosh, cosf, coshf, cosl, coshl |
<math.h> |
For additional compatibility information, see Compatibility.
Example
See the example in sin, sinf, sinl, sinh, sinhf, sinhl.
.NET Framework Equivalent
See Also
Floating-Point Support
acos, acosf, acosl
asin, asinf, asinl
atan, atanf, atanl, atan2, atan2f, atan2l
_matherr
sin, sinf, sinl, sinh, sinhf, sinhl
tan, tanf, tanl, tanh, tanhf, tanhl
_CIcos