这个 JAVA朗,数学。谭() 返回角度的三角切线。
null
- 如果参数为NaN或无穷大,则返回的结果为NaN。
- 如果参数为零,则结果为零,符号与参数相同。
语法:
public static double tan(double angle) Parameters : The function has one mandatory parameter angle which is in radians.
返回: 该函数返回角度的三角切线。
例1: 来展示java的工作原理。朗,数学。tan()方法。
// Java program to demonstrate working
// of java.lang.Math.tan() method
import
java.lang.Math;
class
Gfg {
// driver code
public
static
void
main(String args[])
{
double
a =
30
;
// converting values to radians
double
b = Math.toRadians(a);
System.out.println(Math.tan(b));
a =
45
;
// converting values to radians
b = Math.toRadians(a);
System.out.println(Math.tan(b));
a =
60
;
// converting values to radians
b = Math.toRadians(a);
System.out.println(Math.tan(b));
a =
0
;
// converting values to radians
b = Math.toRadians(a);
System.out.println(Math.tan(b));
}
}
输出:
0.5773502691896257 0.9999999999999999 1.7320508075688767 0.0
例2: 来展示java的工作原理。朗,数学。参数为NAN或无穷大时的tan()方法。
// Java program to demonstrate working
// of java.lang.Math.tan() method infinity case
import
java.lang.Math;
public
class
GFG {
public
static
void
main(String[] args)
{
double
positiveInfinity =
Double.POSITIVE_INFINITY;
double
negativeInfinity =
Double.NEGATIVE_INFINITY;
double
nan = Double.NaN;
double
result;
// Here argument is negative infinity,
// output will be NaN
result = Math.tan(negativeInfinity);
System.out.println(result);
// Here argument is positive infinity,
// output will also be NaN
result = Math.tan(positiveInfinity);
System.out.println(result);
// Here argument is NaN, output will be NaN
result = Math.tan(nan);
System.out.println(result);
}
}
输出:
NaN NaN NaN
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END