![]() |
VOOZH | about |
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.
public static double Math.toDegrees(double rad)
Important Points:
Example 1: In this example, we will convert the standard radian values to degrees.
180.0 90.0 45.0
Example 2: In this example, we are trying to convert the negative radians into degrees.
-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: