strictmath_Java StrictMath cos()方法与示例
strictmath
StrictMath類cos()方法 (StrictMath Class cos() method)
cos() method is available in java.lang package.
cos()方法在java.lang包中可用。
cos() method is used to return the trigonometric cosine of an angle of the given parameter in the method. Here, cos stands for cosine of an angle.
cos()方法用于返回該方法中給定參數的角度的三角余弦值 。 在這里,cos代表一個角度的余弦。
cos() method is a static method so it is accessible with the class name and if we try to access the method with the class object then we will not get any error.
cos()方法是一個靜態方法,因此可以使用類名進行訪問,如果嘗試使用類對象訪問該方法,則不會出現任何錯誤。
In this method we pass only radians type argument (i.e. First we convert given argument in radians by using toRadians() method of StrictMath class then after we will pass the same variable in cos() method).
在此方法中,我們僅傳遞弧度類型的參數(即,首先,我們使用StrictMath類的toRadians()方法將給定的參數轉換為弧度,然后在cos()方法中傳遞相同的變量)。
Syntax:
句法:
public static double cos(double d);Parameter(s):
參數:
double d – represents the double type value whose trigonometric cosine value to be found.
double d –表示要找到其三角余弦值的double類型值。
Return value:
返回值:
The return type of this method is double – it returns trigonometric cosine value of the given parameter.
此方法的返回類型是雙 -返回給定參數的三角余弦值。
Note:
注意:
If we pass NaN as an argument, method returns the same value (NaN).
如果我們將NaN作為參數傳遞,則方法將返回相同的值(NaN)。
If we pass an infinity, method returns NaN.
如果傳遞無窮大,則方法返回NaN。
Example:
例:
// Java program to demonstrate the example // of cos(double d) method of StrictMath Class.public class Cos {public static void main(String[] args) {// variable declarationsdouble d1 = 7.0 / 0.0;double d2 = -7.0 / 0.0;double d3 = 60.0;// Display previous value of d1,d2 and d3System.out.println("d1: " + d1);System.out.println("d2: " + d2);System.out.println("d3: " + d3);// By using toRadians() method to convert absolute value into radians.d1 = StrictMath.toRadians(d1);d2 = StrictMath.toRadians(d2);d3 = StrictMath.toRadians(d3);// Here , we will get (NaN) because we are // passing parameter whose value is (infinity)System.out.println("StrictMath.cos(d1): " + StrictMath.cos(d1));// Here , we will get (NaN) because we are// passing parameter whose value is (-infinity)System.out.println("StrictMath.cos(d2): " + StrictMath.cos(d2));// Here we will find cosine of d3 by using cos() methodSystem.out.println("StrictMath.cos(d3): " + StrictMath.cos(d3));} }Output
輸出量
d1: Infinity d2: -Infinity d3: 60.0 StrictMath.cos(d1): NaN StrictMath.cos(d2): NaN StrictMath.cos(d3): 0.5000000000000001翻譯自: https://www.includehelp.com/java/strictmath-cos-method-with-example.aspx
strictmath
總結
以上是生活随笔為你收集整理的strictmath_Java StrictMath cos()方法与示例的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 用于数据分析的Python – Pand
- 下一篇: mysql什么情况会刷脏页_mysql-