Java cos() 方法

Java 教程 · 2019-02-08 14:26:52

cos() 方法用于返回指定double类型参数的余弦值。

语法

double cos(double d)

参数

  • d -- 任何原生数据类型。

返回值

返回指定double类型参数的余弦值。

实例

public class Test{ 
    public static void main(String args[]){
    
        double degrees = 45.0;
        double radians = Math.toRadians(degrees);

        System.out.format("pi 的值为 %.4f%n", Math.PI);
        System.out.format("%.1f 度的余弦值为 %.4f%n", degrees, Math.cos(radians));

    }
}

编译以上程序,输出结果为:

pi 的值为 3.1416
45.0 度的余弦值为 0.7071

点击查看所有 Java 教程 文章: https://www.codercto.com/courses/l/12.html

查看所有标签

Head First WordPress

Head First WordPress

Siarto Jeff / O'Reilly Media / 2010-02-15 / USD 34.99

Whether you're promoting your business or writing about your travel adventures, "Head First WordPress" will teach you not only how to make your blog look unique and attention-grabbing, but also how to......一起来看看 《Head First WordPress》 这本书的介绍吧!

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具