VOOZH about

URL: https://www.geeksforgeeks.org/java/java-math-todegrees-method/

⇱ Java Math toDegrees() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Java Math toDegrees() Method

Last Updated : 12 May, 2025

The toDegrees() method comes under the java.lang.Math package. This method is used to convert an angle from radians to its equivalent degrees. This method is useful in mathematical computations where angle conversion is required, for example, trigonometry, geometry etc.

Note: The conversion from radians to degrees is not always exact due to floating point precision. The users should not expect cos(toRadians(90.0)) to exactly equal 0.0.

Syntax of toDegrees() Method

public static double Math.toDegrees(double rad)

  • Parameter: rad: This parameter is an angle in radians which we want to convert in degrees.
  • Returns: It returns the corresponding angle in degrees as a double.

Important Points:

  • This toDegrees() method belongs to Java Math class.
  • This method accepts a double and returns a double.
  • This method can handle both positive and negative angles.
  • For reverse conversion, use Math.toRadians() method.

Examples of Java Math toDegrees() Method

Example 1: In this example, we will convert the standard radian values to degrees.


Output
180.0
90.0
45.0


Example 2: In this example, we are trying to convert the negative radians into degrees.


Output
-90.0

Explanation: Negative radian is correctly converted into the equivalent negative degree.


Example 3: In this example, we will take the user input for radians, and then use toDegrees() method to convert it into the degree.

Output:

👁 Output
Comment
Article Tags: