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 官宣新年祝福语简短