static double toDegrees(double angrad)
描述 (Description)
java.lang.Math.toDegrees(double angrad)将以弧度为单位的角度转换为以度为单位测量的近似等效角度。 从弧度到度数的转换通常是不精确的; 用户不应期望cos(toRadians(90.0))完全等于0.0。
声明 (Declaration)
以下是java.lang.Math.toDegrees()方法的声明
public static double toDegrees(double angrad)
参数 (Parameters)
angrad - 角度,以弧度表示
返回值 (Return Value)
此方法以度为单位返回角度angrad的测量值。
异常 (Exception)
NA
例子 (Example)
以下示例显示了lang.Math.toDegrees()方法的用法。
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 degrees
x = Math.toDegrees(x);
y = Math.toDegrees(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(2578.3100780887044)=1.0
Math.tanh(-10313.240312354817)=-1.0