Java Math - asin() Method
The java.lang.Math.asin() method returns arc sine of a value. The returned value will be in the range -𝜋/2 through 𝜋/2. In special cases it returns the following:
- If the argument is NaN or its absolute value is greater than 1, then the result is NaN.
- If the argument is zero, then the result is a zero with the same sign as the argument.
Note: asin() is the inverse of sin().
Syntax
public static double asin(double a)
Parameters
a |
Specify the value whose arc sine is to be returned. |
Return Value
Returns the arc sine of the argument.
Exception
NA.
Example:
In the example below, asin() method is used to find out the arc sine of the given values.
import java.lang.*; public class MyClass { public static void main(String[] args) { System.out.println(Math.asin(0.5)); System.out.println(Math.asin(1)); System.out.println(Math.asin(2)); } }
The output of the above code will be:
0.5235987755982989 1.5707963267948966 NaN
❮ Java.lang - Math