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 教师闺蜜祝福语简短