java.lang.StrictMath.atan()是StrictMath類的內置方法,用於返回給定參數的切線。它返回的角度在-pi /2和pi /2的範圍內。它產生兩個特殊結果:
- 如果傳遞的參數為NaN,則輸出為NaN。
- 如果傳遞的參數為0,則結果也是0,保留與參數相同的符號。
用法:
public static double atan(double num)
參數:該方法接受一個double類型的參數num,表示要返回其切線的值。
返回值:該方法返回參數的反正切值。
例子:
Input: num = 0.61 Output: 0.5477400137159024 Input: num = 0.0 Output: 0.0 Input: num = -71.0 Output: -1.5567127509720364
下麵的程序演示了java.lang.StrictMath.atan()方法:
示例1:
// Java praogram to illustrate the
// java.lang.StrictMath.atan()
import java.lang.*;
public class Geeks {
public static void main(String[] args)
{
double num1 = 0.70, num2 = 55.00, num3 = 0;
double atanValue = StrictMath.atan(num1);
System.out.println("The arc tangent of " +
num1 + " = " + atanValue);
atanValue = StrictMath.atan(num2);
System.out.println("The arc tangent of " +
num2 + " = " + atanValue);
atanValue = StrictMath.atan(num3);
System.out.println("The arc tangent of " +
num3 + " = " + atanValue);
}
}
輸出:
The arc tangent of 0.7 = 0.6107259643892086 The arc tangent of 55.0 = 1.5526165117219184 The arc tangent of 0.0 = 0.0
示例2:
// Java praogram to illustrate the
// java.lang.StrictMath.atan()
import java.lang.*;
public class Geeks {
public static void main(String[] args)
{
double num1 = -0.52, num2 = -71.00, num3 = 0;
double atanValue = StrictMath.atan(num1);
System.out.println("The arc tangent of " +
num1 + " = " + atanValue);
atanValue = StrictMath.atan(num2);
System.out.println("The arc tangent of " +
num2 + " = " + atanValue);
atanValue = StrictMath.atan(num3);
System.out.println("The arc tangent of " +
num3 + " = " + atanValue);
}
}
輸出:
The arc tangent of -0.52 = -0.4795192919925962 The arc tangent of -71.0 = -1.5567127509720364 The arc tangent of 0.0 = 0.0
相關用法
- Java atan()用法及代碼示例
- Java StrictMath log()用法及代碼示例
- Java StrictMath tan()用法及代碼示例
- Java StrictMath pow()用法及代碼示例
- Java StrictMath exp()用法及代碼示例
- Java StrictMath sin()用法及代碼示例
- Java StrictMath nextUp()用法及代碼示例
- Java StrictMath hypot()用法及代碼示例
- Java StrictMath cosh()用法及代碼示例
- Java StrictMath scalb()用法及代碼示例
- Java StrictMath multiplyExact()用法及代碼示例
- Java StrictMath cos()用法及代碼示例
- Java StrictMath getExponent()用法及代碼示例
- Java StrictMath min()用法及代碼示例
- Java StrictMath signum()用法及代碼示例
注:本文由純淨天空篩選整理自ankita_chowrasia大神的英文原創作品 StrictMath atan() Method in Java。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。