Java toRadians ()方法与示例
java.lang.Math.toRadians(doubleangdeg)将以度为单位的角度转换为以弧度为单位的近似等效角度。从度到弧度的转换通常是不精确的。
示例
在此,角度法是角度,以度为单位。现在让我们看一个例子-
import java.lang.*;
public class MathDemo {
public static void main(String[] args) {
//得到两个double数
double x = 45;
double y = -180;
//将它们转换成弧度
x = Math.toRadians(x);
y = Math.toRadians(y);
//打印这些双精度的双曲正切
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
示例
让我们看另一个例子-
import java.lang.*;
public class MathDemo {
public static void main(String[] args) {
double x = 90.0;
double y = 30.0;
//将它们换算成弧度
x = Math.toRadians(x);
y = Math.toRadians(y);
//打印这些双精度的双曲正切
System.out.println("Math.tanh(" + x + ")=" + Math.tanh(x));
System.out.println("Math.tanh(" + y + ")=" + Math.tanh(y));
}
}输出结果
Math.tanh(1.5707963267948966)=0.9171523356672744 Math.tanh(0.5235987755982988)=0.4804727781564516
热门推荐
10 节日祝福语幽默简短的
11 新年给妹妹祝福语简短
12 周末祝福语正能量简短
13 儿女的生日祝福语简短
14 写给老师祝福语简短大学
15 给老师祝福语简短创意
16 离校退群祝福语简短
17 20岁简短生日祝福语
18 中考祝福语简短卡片大全