Java.lang.Math.toDegrees() 方法
描述
java.lang.Math.toDegrees(double angrad) 将以弧度测量的角度转换为以度为单位测量的大致等效角度。 从弧度到度数的转换通常是不精确的; 用户不应期望 cos(toRadians(90.0)) 完全等于 0.0。
声明
以下是 java.lang.Math.toDegrees() 方法的声明。
public static double toDegrees(double angrad)
参数
angrad − 角度,单位为弧度
返回值
此方法以度为单位返回角度 angrad 的测量值。
异常
NA
示例
下面的例子展示了 lang.Math.toDegrees() 方法的使用。
package com.tutorialspoint;
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

