Java StrictMath asin()方法及示例

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

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程