cosd
计算输入角度的余弦值。
接口定义
C interface:
float cosdf(float x);
double cosd(double x);
double cosd_18(double x);
long double cosdl(long double x);
cosd_18仅在高精度版本提供。
参数
参数名 |
类型 |
描述 |
输入/输出 |
---|---|---|---|
x |
|
表示角度的浮点值。 |
输入 |
返回值
- 返回角度x的余弦函数值y,y ∈ [-1, +1]。
- 输入+0,返回1。
- 输入-0,返回1。
- 输入±∞,返回nan。
- 输入±nan,返回±nan。
依赖
C: "km.h"
示例
C interface:
// 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 * * */
父主题: 三角函数