目录

static double tan(double a)

描述 (Description)

java.lang.Math.tan(double a)返回角度的三角正切。 特殊情况 -

  • 如果参数是NaN或无穷大,则结果为NaN。

  • 如果参数为零,则结果为零,其参数符号相同。

计算结果必须在精确结果的1 ulp范围内。 结果必须是半单调的。

声明 (Declaration)

以下是java.lang.Math.tan()方法的声明

public static double tan(double a)

参数 (Parameters)

a - 以弧度表示的角度。

返回值 (Return Value)

此方法返回参数的正切值。

异常 (Exception)

NA

例子 (Example)

以下示例显示了lang.Math.tan()方法的用法。

package com.iowiki;
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
↑回到顶部↑
WIKI教程 @2018