- Java.lang Package classes
- Java.lang - Home
- Java.lang - Boolean
- Java.lang - Byte
- Java.lang - Character
- Java.lang - Character.Subset
- Java.lang - Character.UnicodeBlock
- Java.lang - Class
- Java.lang - ClassLoader
- Java.lang - Compiler
- Java.lang - Double
- Java.lang - Enum
- Java.lang - Float
- Java.lang - InheritableThreadLocal
- Java.lang - Integer
- Java.lang - Long
- Java.lang - Math
- Java.lang - Number
- Java.lang - Object
- Java.lang - Package
- Java.lang - Process
- Java.lang - ProcessBuilder
- Java.lang - Runtime
- Java.lang - RuntimePermission
- Java.lang - SecurityManager
- Java.lang - Short
- Java.lang - StackTraceElement
- Java.lang - StrictMath
- Java.lang - String
- Java.lang - StringBuffer
- Java.lang - StringBuilder
- Java.lang - System
- Java.lang - Thread
- Java.lang - ThreadGroup
- Java.lang - ThreadLocal
- Java.lang - Throwable
- Java.lang - Void
- Java.lang Package extras
- Java.lang - Interfaces
- Java.lang - Errors
- Java.lang - Exceptions
- Java.lang Package Useful Resources
- Java.lang - Useful Resources
- Java.lang - Discussion
Java - Math.toDegrees() Method
Description
The Java Math toDegrees(double angrad) converts an angle measured in radians to an approximately equivalent angle measured in degrees. The conversion from radians to degrees is generally inexact; users should not expect cos(toRadians(90.0)) to exactly equal 0.0.
Declaration
Syntax
public static double toDegrees(double d)
Parameters
Here is the detail of parameters −
d − A double data type.
Return Value
- This method returns a double value.
Example 1
In this example, we're showing the usage of Math.toDegrees() method to get the degrees of two double numbers. We've created two double variables x and y and initialized them with a given values. Then using Math.toDegrees() method we've printed the corresponding degree values.
public class Test { public static void main(String args[]) { double x = 45.0; double y = 30.0; System.out.println( Math.toDegrees(x) ); System.out.println( Math.toDegrees(y) ); } }
This will produce the following result −
Output
2578.3100780887044 1718.8733853924698
Example 2
In this example, we're showing the usage of Math.toDegrees() method to get the degrees of two float numbers. We've created two float variables x and y and initialized them with a given values. Then using Math.toDegrees() method we've printed the corresponding degree values.
public class Test { public static void main(String args[]) { float x = (float)45.0; float y = (float)30.0; System.out.println( Math.toDegrees(x) ); System.out.println( Math.toDegrees(y) ); } }
This will produce the following result −
Output
2578.3100780887044 1718.8733853924698
Example 3
In this example, we're showing the usage of Math.toDegrees() method to get the degrees of a zero value. We've created two float variables x and y and initialized them with a given values. Then using Math.toDegrees() method we've printed the corresponding degree values.
public class Test { public static void main(String args[]) { float x = (float)0.0; float y = (float)-0.0; System.out.println( Math.toDegrees(x) ); System.out.println( Math.toDegrees(y) ); } }
This will produce the following result −
Output
0.0 -0.0
To Continue Learning Please Login
Login with Google