toDegrees() is an inbuilt method in java that converts argument value to degrees.
Syntax:
Math.toDegrees(double d)
Parameters:
The parameter is mandatory and has to be of a double data type. The passed parameter is thus converted to degrees.
Returns
It returns a value of data-type. The passed argument gets converted to degrees and is returned.
Code#1: Program explaining the implementation of toDegrees()
// Java program for implementation of // toDegrees() method import java.util.*; class GFG { // Driver Code public static void main(String args[]) { double x = 12.0 ; double y = 19.0 ; // conversion of number to degrees using // inbuilt function double xinDegrees = Math.toDegrees(x); double yinDegrees = Math.toDegrees(y); // Prints the number in degrees System.out.println(xinDegrees); System.out.println(yinDegrees); } } |
687.5493541569879 1088.619810748564
Output:
687.5493541569879 1088.619810748564
toRadians() is an inbuilt method in java that converts argument value to radian.
Syntax:
Math.toRadians(double d)
Parameters:
The parameter is mandatory and has to be of a double data type. The passed parameter is thus converted to radians.
Returns
It returns a value of data-type. The passed argument gets converted to radians and is returned.
Code#2: Program explaining the implementation of toRadians()
// Java program for implementation of // toRadians() method import java.util.*; class GFG { // Driver Code public static void main(String args[]) { double x = 12.0 ; double y = 19.0 ; // conversion of number to Radians using // inbuilt function double xinRadians = Math.toRadians(x); double yinRadians = Math.toRadians(y); // Prints the number in Radians System.out.println(xinRadians); System.out.println(yinRadians); } } |
0.20943951023931953 0.33161255787892263