cosd
Compute the cosine of the input angle.
Interface Definition
C interface:
float cosdf(float x);
double cosd(double x);
double cosd_18(double x);
long double cosdl(long double x);
cosd_18 is provided only in the high-precision version.
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
x |
|
Floating-point value representing an angle. |
Input |
Return Value
- The cosine y of angle x is returned. y ∈ [-1, +1]
- If the input is +0, the return value is 1.
- If the input is -0, the return value is 1.
- If the input is ±∞, the return value is NaN.
- If the input is ±NaN, the return value is ±NaN.
Dependencies
C: "km.h"
Examples
C interface:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | // typical usage float x1 = 90.0, x2 = -90.0, x3 = 45.0, x4 = -45.0, x5 = 30.0, x6 = -30.0; float a = 0.0, b = INFINITY, c = -INFINITY, d = NAN; // print result printf("cosd(90.0) = %.15f\n", cosd(x1)); printf("cosd(-90.0) = %.15f\n", cosd(x2)); printf("cosd(45.0) = %.15f\n", cosd(x3)); printf("cosd(-45.0) = %.15f\n", cosd(x4)); printf("cosd(30.0) = %.15f\n", cosd(x5)); printf("cosd(-30.0) = %.15f\n", cosd(x6)); printf("cosd(0.0) = %.15f\n", cosd(a)); printf("cosd(-0.0) = %.15f\n", cosd(-a)); printf("cosd(INFINITY) = %.15f\n", cosd(b)); printf("cosd(-INFINITY) = %.15f\n", cosd(c)); printf("cosd(NAN) = %.15f\n", cosd(d)); /* * cosd(90.0) = 0.000000000000000 * cosd(-90.0) = 0.000000000000000 * cosd(45.0) = 0.707106781186548 * cosd(-45.0) = 0.707106781186548 * cosd(30.0) = 0.866025403784439 * cosd(-30.0) = 0.866025403784439 * cosd(0.0) = 1.000000000000000 * cosd(-0.0) = 1.000000000000000 * cosd(INFINITY) = nan * cosd(-INFINITY) = nan * cosd(NAN) = nan * * */ |
Parent topic: Trigonometric Functions