Close

Java - Math.toRadians() Examples

Java Java API 


Class:

java.lang.Math

java.lang.Objectjava.lang.Objectjava.lang.Mathjava.lang.MathLogicBig

Method:

public static double toRadians(double angdeg)

Converts an angle measured in degrees to an approximately equivalent angle measured in radians. The conversion from degrees to radians is generally inexact.

Parameters:
angdeg - an angle, in degrees
Returns:
the measurement of the angle angdeg in radians.
Since:
1.2


Examples


package com.logicbig.example.math;

public class ToRadiansExample {

public static void main(String... args) {
degree(0);
degree(30);
degree(45);
degree(60);
degree(90);
}

private static void degree(double value) {
double radians = Math.toRadians(value);
System.out.printf("Radian of %s degree = %.3f %n", value, radians);
}
}

Output

Radian of 0.0 degree = 0.000 
Radian of 30.0 degree = 0.524
Radian of 45.0 degree = 0.785
Radian of 60.0 degree = 1.047
Radian of 90.0 degree = 1.571




See Also