Java StrictMath asin()方法及示例

来源:这里教程网 时间:2026-02-17 21:12:57 作者:

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.72Output: 0.80380231893303Input: val = 7.0Output: NANInput: val = 0.0Output: 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.7075844367253556The arc sine value is = NaNThe 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.015985293814825The arc sine value is = NaNThe arc sine value is= 0.0

相关推荐