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


Java StrictMath asin()用法及代碼示例


java.lang.StrictMath.asin()是StrictMath類的內置方法,用於返回指定值的反正弦值。返回的角度在-pi /2和pi /2的範圍內。該方法產生兩個特殊結果:

  • 如果自變量的絕對值大於1或自變量本身是NaN,則結果也是NaN。
  • 如果傳遞的參數為0,則輸出也為0,且符號與參數相同。

用法:

public static double asin(double val)

參數:此方法接受一個雙精度類型的參數val,表示要返回其反正弦值的值。


返回值:該方法返回參數的反正弦值。
例子:

Input: val = 0.72
Output: 0.80380231893303

Input: val = 7.0
Output: NAN

Input: val = 0.0
Output: 0.0

下麵的程序演示了java.lang.StrictMath.asin()方法:
示例1:

// Java program to illustrate the 
// java.lang.StrictMath.asin() 
import java.lang.*; 
  
public class Geeks { 
  
    public static void main(String[] args) 
    { 
  
        double val1 = 0.65, val2 = 3.00, val3 = 0; 
  
        double asinvalue = StrictMath.asin(val1); 
        System.out.println(" The arc sine value is = "+ 
                                            asinvalue); 
  
        asinvalue = StrictMath.asin(val2); 
        System.out.println("The arc sine value is = "+ 
                                            asinvalue); 
                            
        asinvalue = StrictMath.asin(val3); 
        System.out.println("The arc sine value is = "+ 
                                           asinvalue); 
    } 
}
輸出:
The arc sine value is = 0.7075844367253556
The arc sine value is = NaN
The arc sine value is = 0.0

示例2:

// Java program to illustrate the 
// java.lang.StrictMath.asin() 
import java.lang.*; 
  
public class Geeks { 
  
    public static void main(String[] args) 
    { 
  
        double val1 = -0.85, val2 = -2.00, val3 = 0; 
  
        double asinvalue = StrictMath.asin(val1); 
        System.out.println(" The arc sine value is = "+ 
                                            asinvalue); 
  
        asinvalue = StrictMath.asin(val2); 
        System.out.println("The arc sine value is = "+ 
                                            asinvalue); 
  
        asinvalue = StrictMath.asin(val3); 
        System.out.println("The arc sine value is= "+ 
                                            asinvalue); 
    } 
}
輸出:
The arc sine value is = -1.015985293814825
The arc sine value is = NaN
The arc sine value is= 0.0


相關用法


注:本文由純淨天空篩選整理自ankita_chowrasia大神的英文原創作品 StrictMath asin() Method in Java With Examples。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。