Java toDegrees() method with Example
Last Updated :
12 Apr, 2018
The java.lang.Math.toDegrees() is used to convert an angle measured in radians to an approximately equivalent angle measured in degrees.
Note: The conversion from radians to degrees is generally inexact; users should not expect cos(toRadians(90.0)) to exactly equal 0.0.
Syntax:
public static double toDegrees(double rad)
Parameter:
rad : This parameter is an angle in radians which
we want to convert in degrees.
Return :
This method returns the measurement of the angle
rad in degrees.
Example: To show working of java.lang.Math.toDegrees() method.
import java.lang.Math;
class Gfg {
public static void main(String args[])
{
double rad = Math.PI;
System.out.println(Math.toDegrees(rad));
rad = (Math.PI) / 2 ;
System.out.println(Math.toDegrees(rad));
rad = (Math.PI) / 4 ;
System.out.println(Math.toDegrees(rad));
}
}
|
Output:
180.0
90.0
45.0
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...