Java toDegrees() method with Example
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.
// Java program to demonstrate working // of java.lang.Math.toDegrees() method import java.lang.Math; class Gfg { // driver code public static void main(String args[]) { // value of PI in degrees double rad = Math.PI; System.out.println(Math.toDegrees(rad)); // value of PI/2 in degrees rad = (Math.PI) / 2 ; System.out.println(Math.toDegrees(rad)); // value of PI/4 in degrees rad = (Math.PI) / 4 ; System.out.println(Math.toDegrees(rad)); } } |
chevron_right
filter_none
Output:
180.0 90.0 45.0
Recommended Posts:
- StrictMath toDegrees() Method in Java
- toDegrees() and toRadians() in Java
- Java lang.Long.numberOfLeadingZeros() method in Java with Examples
- Java.util.Collections.rotate() Method in Java with Examples
- Java.util.Collections.disjoint() Method in java with Examples
- Java lang.Long.highestOneBit() method in Java with Examples
- Java lang.Long.reverse() method in Java with Examples
- Java lang.Long.builtcount() method in Java with Examples
- Java lang.Long.byteValue() method in Java with Examples
- Java.lang.Short toString() method in Java with Examples
- Java lang.Long.numberOfTrailingZeros() method in Java with Examples
- Java lang.Long.lowestOneBit() method in Java with Examples
- Java Clock withZone() method in Java with Examples
- Java.util.ArrayList.addall() method in Java
- Java.lang.string.replace() method in Java
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.