目录

static double toRadians(double angdeg)

描述 (Description)

java.lang.Math.toRadians(double angdeg)将以度为单位的角度转换为以弧度为单位测量的近似等效角度。 从度数到弧度的转换通常是不精确的。

声明 (Declaration)

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

public static double toRadians(double angdeg)

参数 (Parameters)

angdeg - 角度,以度为单位

返回值 (Return Value)

此方法以弧度为单位返回角度angdeg的测量值。

异常 (Exception)

NA

例子 (Example)

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

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 hyperbolic tangent of these doubles
      System.out.println("Math.tanh(" + x + ")=" + Math.tanh(x));
      System.out.println("Math.tanh(" + y + ")=" + Math.tanh(y));
   }
}

让我们编译并运行上面的程序,这将产生以下结果 -

Math.tanh(0.7853981633974483)=0.6557942026326724
Math.tanh(-3.141592653589793)=-0.99627207622075
↑回到顶部↑
WIKI教程 @2018