Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App

Related Articles

PHP | rad2deg() Function

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

Measurement of Angle is one of the foundation stones of Geometry and Trigonometry, and the two most commonly used methods of measurement are Degrees and Radians. Because of it’s simplicity many prefer to use degree over Radian. Some of the reasons that makes degrees more preferable are:

  • Degrees may not be much efficient while calculating derivatives or complicated relations, but it is easy to understand and visualize.
  • While Radian is in fact a ratio, Degree is considered as the unit of rotational displacement where a complete rotation is equivalent to 360 Degrees. Because of this simplicity students are taught and are much more familiar to Degrees rather than Radians.

Thus in some cases we may require to convert from radians to degrees, this is where the method rad2deg() comes in aid.


float rad2deg($value)

Parameters: The function takes a single parameter $value which is of type float that represents an angle in Radians.

Return Type: This function returns a float value that represents the Degree equivalent of the given angle $value.


Input :  $value = M_PI_4;
Output : 45

Input : $value = M_PI_2;
Output : 90

Input : $value = M_PI;
Output : 180

Below program illustrates the working of rad2deg() in PHP:

// PHP code to illustrate the working of rad2deg()
$rad = M_PI;
$k = 1;
for(;$k<=8;$k*=2, $rad/=2)
       echo 'pi/'.$k.' = '.rad2deg($rad)."\n";
       echo 'pi = '.rad2deg($rad)."\n";


pi = 180
pi/2 = 90
pi/4 = 45
pi/8 = 22.5

Important points to note:

  • It calculates the Degrees equivalent of the angle given in Radians.
  • The counterpart of the method is rad2deg().
  • This method produces highly accurate results but is not much time efficient.


My Personal Notes arrow_drop_up
Last Updated : 09 Mar, 2018
Like Article
Save Article
Similar Reads
Related Tutorials