java math.cos_Java Math类静态double cos(double d)示例

java math.cos

数学类静态双cos(double d) (Math Class static double cos(double d))

  • This method is available in java.lang package.

    此方法在java.lang包中可用。

  • This method is used to return the trigonometric cosine of an angle of the given parameter in the method. 

    此方法用于返回该方法中给定参数的角度的三角余弦。

  • In this method, cos stands for cosine of an angle.

    在此方法中,cos代表角度的余弦。

  • This is a static method so this method is accessible with the class name too. 

    这是一个静态方法,因此也可以使用类名访问此方法。

  • The return type of this method is double that means it returns the cosine value of the given angle and the value is of double type. 

    此方法的返回类型是double,这意味着它将返回给定角度的余弦值,并且该值是double类型。

  • In this method, we pass only one parameter as an argument in the method of Math class and the given parameter is those parameters for which we have to find the cosine of an angle. 

    在此方法中,我们仅将一个参数作为参数传递给Math类的方法,并且给定参数是那些我们必须找到角度的余弦值的参数。

  • In this method, we pass only radians type argument (i.e. First we convert given argument in radians by using toRadians() method of Math class then after we will pass the same variable in cos() method). 

    在此方法中,我们仅传递弧度类型的参数(即,首先,我们使用Math类的toRadians()方法将给定参数转换为弧度,然后在cos()方法中传递相同的变量)。

  • This method does not throw any exception.

    此方法不会引发任何异常。

Syntax:

句法:

    public static double cos(double d){
}

Parameter(s):

参数:

double d – A double value (angle) whose cosine value to be found.

double d –要查找其余弦值的双精度值(角度)。

Note:

注意:

  • If we pass "NaN", it returns "NaN".

    如果我们传递“ NaN”,则返回“ NaN”。

  • If we pass an infinity, it returns "NaN".

    如果传递无穷大,则返回“ NaN”。

Return value:

返回值:

The return type of this method is double, it returns the cosine value of the given angle.

此方法的返回类型为double ,它返回给定角度的余弦值。

Java程序演示cos(double d)方法的示例 (Java program to demonstrate example of cos(double d) method)

// Java program to demonstrate the exammple of cos(double d) 
// method of Math Class
class CosMethod {
public static void main(String[] args) {
// Here we are declaring few variables
double d1 = 7.0 / 0.0;
double d2 = -7.0 / 0.0;
double d3 = 60.0;
// Display previous value of d1,d2 and d3
System.out.println(" Before implementing cos() so the value of d1 is :" + d1);
System.out.println(" Before implementing cos() so the value of d2 is :" + d2);
System.out.println(" Before implementing cos() so the value of d3 is :" + d3);
// By using toRadians() method to convert 
// absolute value into radians
d1 = Math.toRadians(d1);
d2 = Math.toRadians(d2);
d3 = Math.toRadians(d3);
// Here , we will get (NaN) because we are passing 
// parameter whose value is (infinity)
System.out.println("After implementing cos() so the value of d1 is :" + Math.cos(d1));
// Here , we will get (NaN) because we are passing 
// parameter whose value is (-infinity)
System.out.println("After implementing cos() so the value of d2 is :" + Math.cos(d2));
// Here we will find cosine of d3 by using cos() method
System.out.println("After implementing cos() so the value of d3 is :" + Math.cos(d3));
}
}

Output

输出量

E:\Programs>javac AtanMethod.java
E:\Programs>java AtanMethod
Before implementing cos() so the value of d1 is :Infinity
Before implementing cos() so the value of d2 is :-Infinity
Before implementing cos() so the value of d3 is :60.0
After implementing cos() so the value of d1 is :NaN
After implementing cos() so the value of d2 is :NaN
After implementing cos() so the value of d3 is :0.5000000000000001

翻译自: https://www.includehelp.com/java/math-class-static-double-cos-double-d-with-example.aspx

java math.cos

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.pswp.cn/news/379906.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

web安全---SSRF漏洞

简介 SSRF:服务器请求伪造,是一种攻击者构造形成由服务端发起请求 的一个安全漏洞。一般情况下,SSRF攻击的目标是从外网无法访问的内部系统(正是因为它是由服务端发起的,所以它能够请求到与它相连而与外网隔离的内部系…

集合——对象数组(引用数据类型数组)

案例:我有5个学生,请把这个5个学生的信息存储到引用数据类型数组中,并遍历数组,获取得到每一个学生的信息。 思路分析:首先,想要创建学生对象,就得有学生这个类,所以,首…

提升应用视觉Android效果的10个UI技巧

在Android应用开发中,风格和设计或许不是最关键的要素,但它们在决定Android应用成功与否上确实扮演重要的角色。以下是10个Android应用的UI设计技巧,还有个附加技巧,能够提供你的Android应用的视觉吸引力。 技巧1:使用…

kotlin中判断字符串_Kotlin程序查找字符串中字符的频率

kotlin中判断字符串Given a string and a character, we have to find the frequency of the character in the string. 给定一个字符串和一个字符,我们必须找到字符串中字符的频率。 Example: 例: Input:string "IncludeHelp"character to…

OD使用

0x01 功能界面 序号1是汇编代码对应的地址窗口序号2是汇编对应的十六进制机器码窗口序号3是反汇编窗口序号4是反汇编代码对应的注释信息窗口序号5是寄存器信息窗口序号6是当前执行到的反汇编代码的信息窗口序号7是数据所在的地址序号8是数据的十六进制编码信息,序号…

windows mobile 开发总结--菜单

在开发时经常要创建菜单,并且动态显示和隐藏菜单或者是某个子菜单。以下就是实现的方法: 1。创建并显示菜单,先在资源里添加菜单,然后如下代码 SHMENUBARINFO mbi; ZeroMemory(&mbi, sizeof(SHMENUBARINFO)); mbi.cbSizesizeof(SHMENUBAR…

Java——集合的概述

* A:集合的由来* 数组是容器,集合也是容器* 数组的弊端:数组的长度是固定的,当添加的元素超过了数组的长度时,需要对数组重新定义,太麻烦* Java内部给我们提供了集合类,可以存储任意对象&#x…

排序算法中平均时间复杂度_操作系统中的作业排序(算法,时间复杂度和示例)...

排序算法中平均时间复杂度作业排序 (Job sequencing) Job sequencing is the set of jobs, associated with the job i where deadline di > 0 and profit pi > 0. For any job i the profit is earned if and only if the job is completed by its deadline. To complet…

python---文件处理

0x01 打开一个文件 python中内置了文件对象,通过open()函数就可以制定模式打开指定文件,并创建文件对象。该函数的格式如下: open(file[,moder[,buffering-1]])file:指定要打开或创建的文件名称,如果该文件不存在当前…

简易而又灵活的Javascript拖拽框架(四)

一、开篇 似乎拖拽已经被写烂了,没得写的了,可是我这次又来了~ 上一次写的是跨列拖放,这次我要带给大家的是跨页拖放。 可以到这里来看看效果:示例效果 说明:1、如果将方框拖动到页签上立刻释放掉的话&…

Java——集合的基本功能测试

* 1,boolean add<E,e> 添加* 确保此 collection 包含指定的元素&#xff08;可选操作&#xff09;。* 参数&#xff1a;e - 确定此 collection 中是否存在的元素。E - 代表Object类&#xff0c;说明该add可以添加任何对象&#xff0c;任意对象都是Object的子类对象&…

《那些年啊,那些事——一个程序员的奋斗史》——78

招人风波之后&#xff0c;就很少见武总往18楼跑了&#xff0c;大部分时间都是坐在22楼的隔间。而武总对段伏枥的抱怨&#xff0c;也仅仅只有那次&#xff0c;后来就再也没有提过。对于段伏枥而言&#xff0c;还要不要招新人&#xff0c;后续如何去招新人&#xff0c;已经不是自…

python---异常处理结构

python中提供了很多不同形式的异常处理结构&#xff0c;其基本思路都是先尝试执行代码&#xff0c;再处理可能发生的错误。 try…except… 在python异常处理结构中&#xff0c;try…except…使用最为频繁&#xff0c;其中try子句中的代码块为可能引发异常的语句&#xff0c;e…

用css网站布局之十步实录 (转载)

第一步&#xff1a;规划网站http://www.52css.com/article.asp?id175 第二步&#xff1a;创建html模板及文件目录等http://www.52css.com/article.asp?id176 第三步&#xff1a;将网站分为五个div 网页基本布局http://www.52css.com/article.asp?id177 第四步&#xff1a;网…

Java——集合转数组并对其进行遍历

* A&#xff1a;集合的遍历* 其实就是以此获取集合中的每一个元素* B&#xff1a;案例* 把集合转成数组&#xff0c;可以实现集合的遍历* public Object[] toArray() 按适当顺序&#xff08;从第一个到最后一个元素&#xff09;返回包含此列表中所有元素的数组。…

鱼油账号记录程序(续) - 零基础入门学习Delphi39

鱼油账号记录程序&#xff08;续&#xff09; 让编程改变世界 Change the world by program 课件同上一讲&#xff0c;这一讲主要演示编程操作和修改程序&#xff01; [buy] 获得所有教学视频、课件、源代码等资源打包 [/buy] [Downlink hrefhttp://kuai.xunlei.com/d/LDKX…

python---Socket编程

Sockte是计算机之间进行网络通信的一套程序接口&#xff0c;相当于在发送端和接收端之间建立一个通信管道。在实际应用中&#xff0c;一些远程管理软件和网络安全软件大多数依赖于Socket来实现特定功能&#xff0c;由于TCP方式在网络编程中应用非常频繁&#xff0c;此处将对TCP…

格式转换-----PDF格式研究笔记(一)

格式转换-----PDF格式研究笔记&#xff08;一&#xff09; 现在我的几个计划都需要我能够对PDF格式进行解码&#xff0c;所以找了一下资料&#xff0c;找到了一个PDF1.3的手册&#xff0c;特放出下载&#xff0c;如果谁有更高版本的&#xff0c;请给我一份&#xff0c;谢谢。 …

(X)HTML嵌套规则

本文整理于互联网~ 简单认识了块元素和内嵌元素以后&#xff0c;下面就可以罗列 XHTML 标签的嵌套规则了&#xff1a; 1. 块元素可以包含内联元素或某些块元素&#xff0c;但内联元素却不能包含块元素&#xff0c;它只能包含其它的内联元素&#xff1a;<div><h1>&…

Java——集合带All的功能演示

package com.wsq.collection;import java.util.ArrayList; import java.util.Collection; public class Demo4_CollectionAll {public static void main(String[] args) {demo1(); //c1.addAll(c2);将c2整个集合给添加到c1中,即&#xff0c;c2集合中的每…