toDegrees() and toRadians() in Java
Last Updated :
03 Mar, 2018
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()
import java.util.*;
class GFG {
public static void main(String args[])
{
double x = 12.0 ;
double y = 19.0 ;
double xinDegrees = Math.toDegrees(x);
double yinDegrees = Math.toDegrees(y);
System.out.println(xinDegrees);
System.out.println(yinDegrees);
}
}
|
Output:
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()
import java.util.*;
class GFG {
public static void main(String args[])
{
double x = 12.0 ;
double y = 19.0 ;
double xinRadians = Math.toRadians(x);
double yinRadians = Math.toRadians(y);
System.out.println(xinRadians);
System.out.println(yinRadians);
}
}
|
Output:
0.20943951023931953
0.33161255787892263
Share your thoughts in the comments
Please Login to comment...