ThisCalculator

Everyday

Java Convert Radians to Degrees: Math.toDegrees

Updated · Standard formula, shown below

Angle in degrees 90.00 °
Math.toDegrees result
90.00 °
Result
Angle in radians
1.5707963268 rad
You entered

Java Convert Radians to Degrees: Math.toDegrees

To convert radians to degrees in Java, call Math.toDegrees(radians); it returns the equivalent angle in degrees as a double. Enter an angle measured in radians, and the result is its degree measure—for example, Math.toDegrees(Math.PI) returns 180.0.

Formula

Radians and degrees measure the same kind of quantity: an angle. One full turn is 2π radians or 360 degrees, so the conversion formula is:

degrees = radians × 180 / π

  • radians is the input angle, measured in radians.
  • degrees is the equivalent angle, measured in degrees.
  • π is the mathematical constant pi, approximately 3.141592653589793.

In Java, Math.toDegrees(radians) performs this conversion. The calculator block shows the same mathematical relationship; its two outputs represent the formula result and the equivalent Java method result.

Worked Example

Using the default input, r = 1.5707963267948966 radians:

  1. Apply the conversion formula: degrees = r × 180 / π.
  2. Substitute the input: degrees = 1.5707963267948966 × 180 / π.
  3. Evaluate the expression: degrees = 90.0.

Rounded to two decimal places, the result is 90.00°. In Java, Math.toDegrees(1.5707963267948966) gives approximately 90.0; the last displayed digits can depend on floating-point representation and formatting.

Convert Radians in Java

The usual conversion is a direct call to the static method in java.lang.Math, which Java makes available without an import:

double radians = Math.PI / 3;
double degrees = Math.toDegrees(radians);

System.out.println(degrees); // approximately 59.99999999999999

The mathematical result is 60 degrees. The printed value illustrates that decimal fractions are represented using finite-precision binary floating-point numbers, so a computed result may be extremely close to an exact whole number without displaying exactly that number.

You can also convert a numeric literal or the result of another calculation:

double degrees = Math.toDegrees(0.5);
double angle = Math.toDegrees(Math.atan2(y, x));

The second example is useful when an angle comes from Math.atan2. That method returns radians, so convert its result if the rest of your program expects degrees. The variables x and y must be defined as numeric values before this code is used.

How the Conversion Works

A radian is defined by the relationship between an angle and the radius of a circle: an angle of one radian subtends an arc whose length equals the radius. A complete circle contains 2π radians, which corresponds to 360 degrees. Dividing both measures gives π radians per 180 degrees, and therefore one radian is 180 / π degrees—about 57.2958 degrees.

For example, π / 2 radians is one quarter of a full turn, or 90 degrees. Likewise, π radians is a half turn, or 180 degrees. These familiar values are often useful for checking a conversion or writing tests.

Java’s Math.toDegrees is intended for converting an angle from radians to degrees. It returns a double; it does not round the result to an integer or format it for display. If a user interface should show a fixed number of decimal places, handle that separately when formatting the value.

Choosing the Right Method and Units

Use Math.toDegrees when a value is in radians and you need degrees. Use Math.toRadians(degrees) for the reverse direction. Both methods belong to Math and return double values.

  • Java trigonometric functions such as Math.sin, Math.cos, and Math.tan take angles in radians.
  • Inverse trigonometric functions such as Math.asin, Math.acos, and Math.atan return angles in radians.
  • If your input or output is in degrees, convert at the boundary where the value enters or leaves code that expects radians.

For instance, Math.sin(Math.toRadians(30)) evaluates the sine of 30 degrees. Passing 30 directly to Math.sin would instead mean 30 radians, a different angle. Keep units clear in variable names or documentation, such as angleRadians and angleDegrees, to prevent that mix-up.

Common Mistakes and Limits

The most common error is assuming Java’s trigonometric methods use degrees. They use radians, so a degree value must be converted before being passed to sin, cos, or tan. A related mistake is applying Math.toDegrees twice: once a value has been converted, converting it again treats the degree number as though it were radians.

  • Do not confuse conversion with rounding. Math.toDegrees converts the unit but preserves a floating-point result. Round only if your application requires it.
  • Expect small floating-point differences. Values involving π often cannot be represented exactly as double. Compare calculated values with an appropriate tolerance instead of relying on exact equality when numerical rounding is possible.
  • Remember that the method does not normalize angles. Negative angles and angles larger than one turn are converted proportionally. For example, 4π radians becomes 720 degrees, not 0 degrees.
  • Keep the unit attached to the value conceptually. A plain double does not record whether it represents radians or degrees.

If you need a normalized direction, specify the desired range—such as 0 inclusive to 360 exclusive—and normalize separately. That is a distinct operation from radians-to-degrees conversion, and the correct range depends on the application.

Frequently Asked Questions

What is the Java method to convert radians to degrees?
Use Math.toDegrees(radians). It accepts a double value in radians and returns the equivalent value in degrees as a double.

How do I convert degrees to radians in Java?
Call Math.toRadians(degrees). For example, Math.toRadians(180) returns approximately Math.PI.

Does Java Math.sin use degrees or radians?
Math.sin takes its argument in radians. Convert a degree input first, for example Math.sin(Math.toRadians(45)).

Why does Math.toDegrees return a value like 59.99999999999999?
The input and calculation use binary floating-point arithmetic, which cannot represent every decimal value exactly. The result is a close approximation; format or round it for display when appropriate.

Does Math.toDegrees limit the answer to 0–360 degrees?
No. It applies the conversion factor without wrapping the angle. Negative inputs remain negative, and inputs representing multiple turns produce values greater than 360 degrees.

Related

Formula used
in r | Angle in radians | rad | 1.5707963267948966 | 0
out d | Angle in degrees | ° | r * 180 / pi | 2
out m | Math.toDegrees result | ° | r * 180 / pi | 2

Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.