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://codercto.com/courses/l/12.html

查看所有标签

Software Paradigms

Software Paradigms

Stephen H. Kaisler / Wiley-Interscience / 2005-03-17 / USD 93.95

Software Paradigms provides the first complete compilation of software paradigms commonly used to develop large software applications, with coverage ranging from discrete problems to full-scale applic......一起来看看 《Software Paradigms》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具