Java Math asin()方法及实例

来源:这里教程网 时间:2026-02-17 20:56:54 作者:

Java Math asin()方法及实例

java.lang.Math.asin()返回 -pi/2和pi/2 之间的角度的正弦弧线。

如果参数是NaN或其绝对值大于1,那么结果是NaN。如果参数是零,那么结果是一个与参数符号相同的零。

语法:

public static double asin(double angle)

参数:
angle :要返回其正弦弧线的值。

返回:

该方法返回参数的正弦弧度。

例1: 展示java.lang.Math.asin()方法的工作。

// Java program to demonstrate working// of java.lang.Math.asin() methodimport java.lang.Math; class Gfg {     // driver code    public static void main(String args[])    {        double a = Math.PI;         // Output is NaN, because Math.PI gives 3.141 value        // greater than 1        System.out.println(Math.asin(a));         // convert Math.PI to radians        double b = Math.toRadians(a);         System.out.println(Math.asin(b));         double c = 1.0;        System.out.println(Math.asin(c));         double d = 0.0;        System.out.println(Math.asin(d));         double e = -1.0;        System.out.println(Math.asin(e));         double f = 1.5;         // value of f does not lie in between -1 and 1        // so output is NaN        System.out.println(Math.asin(f));    }}

输出

NaN0.0548586473412512041.57079632679489660.0-1.5707963267948966NaN

相关推荐