Java Math toRadians() Method
The toRadians() method of Java Math class converts an angle measured in degrees to an approximately equivalent angle measured in radian.
Syntax:
public static double toRadians (double angdeg)
Parameters
The parameter ‘angdeg’ represents an angle measured in degrees.
Return Value:
The toRadians() method returns the an inexact angdeg measurement in radians.
Example 1:
public class JavaMathToRadiansExample1 {
public static void main(String[] args) {
double a=67;
//converts a degree angle to an approximately equivalent angle measured in radian
System.out.println("Degree Angle "+ a+" converted in radian = "+Math.toRadians(a));
}
}
Output:
Degree Angle 67.0 converted in radian = 1.1693705988362009
Example 2:
public class JavaMathToRadiansExample2 {
public static void main(String[] args) {
double a=Double.MIN_VALUE;
//converts a degree angle to an approximately equivalent angle measured in radian
System.out.println("Degree Angle "+ a+" converted in radian = "+Math.toRadians(a));
}
}
Output:
Degree Angle 4.9E-324 converted in radian = 0.0
Example 3:
public class JavaMathToRadiansExample3 {
public static void main(String[] args) {
double a=-0d;
//converts a degree angle to an approximately equivalent angle measured in radian
System.out.println("Degree Angle "+ a+" converted in radian = "+Math.toRadians(a));
}
}
Output:
Degree Angle -0.0 converted in radian = -0.0
Example 4:
public class JavaMathToRadiansExample4 {
public static void main(String[] args) {
double a=Double.NaN;
//returns NaN, if the argument passed is NaN
System.out.println("Degree Angle "+ a+" converted in radian = "+Math.toRadians(a));
}
}
Output:
Degree Angle NaN converted in radian = NaN
Example 5:
public class JavaMathToRadiansExample5 {
public static void main(String[] args) {
double a=Double.NEGATIVE_INFINITY;
//returns negative -infinity, if the argument passed is negative infinity
System.out.println("Degree Angle "+ a+" converted in radian = "+Math.toRadians(a));
}
}
Output:
Degree Angle -Infinity converted in radian = -Infinity
