Home >>Java Math Methods >Java Math.tan() method

Java Math.tan() method

Java Math.tan() method

Java Math.tan() in Java Method is used to return the angle tangent in trigonometric.

Syntax

public static double tan(double a) 

Parameter

a =This parameter is used for an angle, in radians

Return

It is used to returns the tangent value of the argument.

  1. This method will return the Tangent value if the statement is positive or negative number.
  2. If NaN or infinity is the argument, the process will return NaN.
  3. When the argument is zero, the method returns zero with the same sign as the argument.

Java Math.tan() method Example 1


public class MyClass  
{  
public static void main(String[] args)   
{  
double x = 60;  
double y = Math.toRadians(x);  
System.out.println(Math.tan(y));  
}  
}  

Output:
1.7320508075688767

Java Math.tan() method Example 2


public class MyClass  
{  
public static void main(String[] args)   
{  
double x = 0.0/0;  
double y = Math.toRadians(x);  
System.out.println(Math.tan(y));  
}  
}  

Output:
NaN

No Sidebar ads