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 妈妈生日祝福语简短励志