Java.lang.StrictMath.toDegrees() Method

Advertisements


Description

The java.lang.StrictMath.toDegrees() method converts an angle measured in radians to an approximately equivalent angle measured in degrees. The conversion from radians to degrees is generally inexact, users should not expect cos(toRadians(90.0)) to exactly equal 0.0.

Declaration

Following is the declaration for java.lang.StrictMath.toDegrees() method

public static double toDegrees(double angrad)

Parameters

  • angrad -- This is an angle, in radians

Return Value

This method returns the measurement of the angle angrad in degrees.

Exception

  • NA

Example

The following example shows the usage of java.lang.StrictMath.toDegrees() method.

package com.tutorialspoint;

import java.lang.*;

public class StrictMathDemo {

  public static void main(String[] args) {
  
    double d1 = 1.5707963267948966 , d2 = 0.0;

    /* converts an angle in radians to an approximately equivalent angle
    in degree.*/

    double degreeValue = StrictMath.toDegrees(d1); 
    System.out.println("Degree value of d1 : " + degreeValue);

    degreeValue = StrictMath.toDegrees(d2); 
    System.out.println("Degree value of d2 : " + degreeValue);
  }
}

Let us compile and run the above program, this will produce the following result:

Degree value of angel d1 : 90.0
Degree value of angel d2 : 0.0



Advertisements
Advertisements