当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。