java.lang.Math.tan(double a)%uA0返回一个角的三角函数正切值。特殊情况:
-
如果参数为NaN或无穷大,那么结果为NaN。
-
如果参数是零,那么结果是相同的符号参数为零。
计算结果必须在1 ulp的确切结果。结果必须具有半单调。
声明
以下是java.lang.Math.tan()方法的声明
public static double tan(double a)
参数
-
a%uA0-- 角度,以弧度为单位。
返回值
此方法返回参数的正切值。
异常
-
NA
例子
下面的例子显示lang.Math.tan()方法的使用。
package com.yiibai import java.lang.* public class MathDemo { public static void main(String[] args) { // get two double numbers numbers double x = 45 double y = -180 // convert them in radians x = Math.toRadians(x) y = Math.toRadians(y) // print the tangent of these doubles System.out.println("Math.tan(" + x + ")=" + Math.tan(x)) System.out.println("Math.tan(" + y + ")=" + Math.tan(y)) } }
让我们来编译和运行上面的程序,这将产生以下结果:
Math.tan(0.7853981633974483)=0.9999999999999999 Math.tan(-3.141592653589793)=1.2246467991473532E-16