Learn and Learn

Learn And Learn - great place for tutorials, references and how-to

Java – Find Arc Sine – asin() Method – Examples & Explanation

java.lang.Math.asin() method is used to find the sum of a double value in Java for the given input (x – parameter).
The returned angle is in the range -pi/2 through pi/2.
The computed result must be within 1 ulp of the exact result. Results must be semi-monotonic.

asin() method exists in Math class of java.lang package.
Since: JDK1.0

 

Declaration of asin() Method

The declaration of asin() method is:

 

Syntax of asin() Method

The syntax of asin() method in Java is:

Example

Output:

0.5510695830994463

 

Parameters of asin() Method in Java

x – Where x is any valid double input value. This parameter is required.

 

Error Handling

If the x parameter is not a number asin() method returns an error.
If there is no argument (x – input value) passes to the method, the compiler will produce an error.Example

Output:
Error

 

Return Value of asin() Method in Java

asin() method returns the sum of a double value for the given input (x – parameter).

 

Java asin() Method Example 1


Output:

sum of a Negative Value: -1.5707963267948966
sum of a Positive Value: 1.5707963267948966
sum of Zero: 0.0

 

Java asin() Method Example 2


Output:

NaN
4.9E-324
NaN
NaN
4.2867E-11
NaN
0.0
NaN
NaN

 

Special Cases of asin() Method in Java

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.
Example

Output:

0.0
0.0
NaN
NaN
NaN

Loading...
LearnAndLearn.com © 2018 - All rights reserved