當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Java Java.lang.StrictMath.atan()用法及代碼示例


描述

這個java.lang.StrictMath.atan() 方法返回一個值的反正切。返回的角度在範圍內-pi/2 through pi/2.它包括這些情況 -

  • 如果參數為NaN,則結果為NaN。
  • 如果自變量為零,則結果為零,其符號與自變量相同。

聲明

以下是聲明java.lang.StrictMath.atan()方法

public static double atan(double a)

參數

a- 這是要返回其反正切的值。

返回值

此方法返回參數的反正切。

異常

NA

示例

下麵的例子展示了 java.lang.StrictMath.atan() 方法的用法。

package com.tutorialspoint;

import java.lang.*;

public class StrictMathDemo {

   public static void main(String[] args) {

      double d1 = 0.20 , d2 = 60.00, d3 = 0;
   
      /* returns the arc tangent of a value, returned angle range is
         -pi/2 to pi/2  */
    
      double dAbsValue = StrictMath.atan(d1); 
      System.out.println("arc tangent of " + d1 + " = " + dAbsValue);

      dAbsValue = StrictMath.atan(d2); 
      System.out.println("arc tangent of " + d2 + " = " + dAbsValue);

      dAbsValue = StrictMath.atan(d3); 
      System.out.println("arc tangent of " + d3 + " = " + dAbsValue);
   }
}

讓我們編譯並運行上麵的程序,這將產生以下結果 -

arc tangent of 0.2 = 0.19739555984988078
arc tangent of 60.0 = 1.554131203080956
arc tangent of 0.0 = 0.0

相關用法


注:本文由純淨天空篩選整理自 Java.lang.StrictMath.atan() Method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。