Groovy Operators

Control Statements

Groovy File Handling

Groovy Error & Exceptions

Groovy Multithreading

Groovy Synchronization

Groovy - toDegrees() method



The toDegrees() method converts the argument value to degrees.

Syntax

double toDegrees(double d)

Parameters

  • d − A double data type.

Return Value

This method returns a double value.

Example - Usage of toDegrees() method for a positive double values

Following is an example of the usage of this method −

Example.groovy

class Example {     
   static void main(String[] args){
      double x = 45.0;
      double y = 30.0;
		
      println( Math.toDegrees(x) );
      println( Math.toDegrees(y) );
   } 
}

Output

When we run the above program, we will get the following result −

2578.3100780887044
1718.8733853924696

Example - Usage of toDegrees() method for zero double values

Following is an example of the usage of this method −

Example.groovy

class Example {     
   static void main(String[] args){
      double x = 0.0;
      double y = 0.0;
		
      println( Math.toDegrees(x) );
      println( Math.toDegrees(y) );
   } 
}

Output

When we run the above program, we will get the following result −

0.0
0.0

Example - Usage of toDegrees() method for negative double values

Following is an example of the usage of this method −

Example.groovy

class Example {     
   static void main(String[] args){
      double x = -45.0;
      double y = -30.0;
		
      println( Math.toDegrees(x) );
      println( Math.toDegrees(y) );
   } 
}

Output

When we run the above program, we will get the following result −

-2578.3100780887044
-1718.8733853924696
groovy_numbers.htm
Advertisements