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 我要结婚祝福语简短
18 婚前女儿生日祝福语简短