该方法返回指定双精度值的余弦。
用法
double cos(double d)
参数
d - 此方法接受 double 数据类型的值。
返回值
此方法返回指定双精度值的余弦。
示例
以下是此方法的使用示例~
class Example {
static void main(String[] args){
double degrees = 45.0;
double radians = Math.toRadians(degrees);
System.out.format("The value of pi is %.4f%n", Math.PI);
System.out.format("The cosine of %.1f degrees is %.4f%n", degrees, Math.cos(radians));
}
}
当我们运行上面的程序时,我们会得到以下结果——
The value of pi is 3.1416 The cosine of 45.0 degrees is 0.7071
相关用法
- Groovy contains()用法及代码示例
- Groovy concat()用法及代码示例
- Groovy collect()用法及代码示例
- Groovy compareTo()用法及代码示例
- Groovy compareToIgnoreCase()用法及代码示例
- Groovy ceil()用法及代码示例
- Groovy matches()用法及代码示例
- Groovy after()用法及代码示例
- Groovy padRight()用法及代码示例
- Groovy exp()用法及代码示例
- Groovy equals()用法及代码示例
- Groovy before()用法及代码示例
- Groovy pow()用法及代码示例
- Groovy sin()用法及代码示例
注:本文由纯净天空筛选整理自 Groovy - cos()。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。