.toDegrees()
The .toDegrees()
method converts an angle, measured in radians, to an approximately equivalent angle, measured in degrees.
Syntax
Math.toDegrees(angle)
The data type of the angle
parameter and return value of the .toDegrees()
method is a double
.
Some edge cases for the .toDegrees()
method include the following:
- If the argument is
NaN
, this method will returnNaN
. - If the argument is
zero
, this method will returnzero
with the same sign as the argument. - If the argument is
infinity
, this method will returninfinity
with the same sign as the argument.
Example
The following example demonstrates the .toDegrees()
method being applied to two variables:
// TestDegree.javapublic class TestDegrees {public static void main(String args[]) {double x = 0.5235987756;System.out.println(Math.toDegrees(x));double y = 1.0471975512;System.out.println(Math.toDegrees(y));}}
This results in the following output:
30.060.0
Contributors
- Anonymous contributor