我要评分
获取效率
正确性
完整性
易理解

tand

Compute the tangent of the input degree.

Interface Definition

C interface:

float tandf(float x);

double tand(double x);

long double tandl(long double x);

Parameters

Parameter

Type

Description

Input/Output

x

  • For tandf, x is of single-precision floating-point type.
  • For tand, x is of double-precision floating-point type.
  • For tandl, x is of long double-precision floating-point type.

Floating-point value of a degree angle.

Input

Return Value

  • Normal range: The tangent of degree x is returned.
  • If the input x = 180 * k (k is an integer), the output is ±0.
  • If the input x = 180 * k + 90 (k is an integer), the output is ±inf.
  • If the input |x| = inf or NaN, the output is NaN.

Dependency

C: "km.h"

Example

C interface:
// typical usage
float x1 = -1.0, x2 = 1.0, x3 = 0.5, x4 = -0.5;
// special handling
float a = 0.0, b = INFINITY, c = -INFINITY, d = NAN;
// print result
printf("tand(1.0) = %.15f\n", tand(x1));
printf("tand(-1.0) = %.15f\n", tand(x2));
printf("tand(0.5) = %.15f\n", tand(x3));
printf("tand(-0.5) = %.15f\n", tand(x4));
printf("tand(0.0) = %.15f\n", tand(a));
printf("tand(-0.0) = %.15f\n", tand(-a));
printf("tand(INFINITY) = %.15f\n", tand(b));
printf("tand(-INFINITY) = %.15f\n", tand(c));
printf("tand(NAN) = %.15f\n", tand(d));
/*
 *  tand(1.0) = -0.017455064928218
 *  tand(-1.0) = 0.017455064928218
 *  tand(0.5) = 0.008726867790759
 *  tand(-0.5) = -0.008726867790759
 *  tand(0.0) = 0.000000000000000
 *  tand(-0.0) = -0.000000000000000
 *  tand(INFINITY) = nan
 *  tand(-INFINITY) = nan
 *  tand(NAN) = nan
 *
 * */