Sign up ×

I run into this occasionally and always forget how to do it.

One of those things that pop up ever so often.

Also, what's the formula to convert angles expressed in radians to degrees and back again?

share|improve this question
I don't see why people are downvoting this; some people aren't mathematically inclined. – thesmallprint Sep 25 '08 at 20:53
its just a matter of phrasing. I rephrased it as a programming problem instead of a math problem, and voila, it fits. – DevelopingChris Sep 25 '08 at 20:56
The title of this question makes no sense. "[B]uilt in method" --- built in to what? – Michael J. Barber Sep 27 '11 at 15:19
i am going to go ask for a method for converting Celsius to Fahrenheit and back, i keep forgetting that one too – Alex Jan 7 '13 at 22:40
StackOverflow is more than a forum for questions and answers. It's a place of reference. I originally put the question here as a reference question, because it's really really common. It belongs here so when someone answers "Just Google it", Google will direct you here. – Hans Sjunnesson Jan 9 '13 at 15:20

9 Answers 9

up vote 158 down vote accepted
radians = degrees * (pi/180)

degrees = radians * (180/pi)

As for implementation, the main question is how precise you want to be about the value of pi. There is some related discussion here

share|improve this answer
Pi = 4 * ArcTan(1) could be used, in case you don't have Pi on you system/calculator or just don't want to type it in with all decimals – Axel Kemper Jan 7 '13 at 23:46
Maybe this wasn't available in 2008, but nowadays you can just use the Math.PI constant. – Bart Feb 24 '14 at 14:19
is this correct?? PI radians = 180 degrees radians = 180 degrees / PI radians = 180/PI * degrees i don't known your formula. why are 180 and PI changed? – Hogun Mar 14 '14 at 6:00
@Hogun Unit labels are not the same thing as algebraic variables. When you say "PI radians = 180 degrees" you are speaking in units, equivalent to saying "1 foot = 12 inches". You don't then take the unit labels and treat them as variables, which would give you the obviously wrong equation "feet = 12*inches". – Dave Costa Mar 15 '14 at 20:19
thank you for reply. you are correct. – Hogun Mar 17 '14 at 4:40

a complete circle in radians is 2*pi. A complete circle in degrees is 360. To go from degrees to radians, it's (d/360) * 2*pi, or d*pi/180.

share|improve this answer

x rads in degrees - > x*180/pi
x degrees in rads -> x*pi/180

I guess if you wanted to make a function for this [in PHP]:

function convert($type, $num) {
    if ($type == "rads") {
          $result = $num*180/pi();

    if ($type == "degs") {
          $result = $num*pi()/180;

    return $result;

Yes, that could probably be written better.

share|improve this answer

180 degrees = PI * radians

share|improve this answer
No, 180 degrees = Pi. – thesmallprint Sep 25 '08 at 20:48
180 degrees = pi radians. – garg Sep 15 '13 at 14:50

360 degrees is 2*PI radians

You can find the conversion formulas at:

share|improve this answer

360 degrees = 2*pi radians

That means deg2rad(x) = x*pi/180 and rad2deg(x) = 180x/pi;

share|improve this answer

pi Radians = 180 degrees

So 1 degree = pi/180 radians

or 1 radian = 180/pi degrees

share|improve this answer

This works well enough for me :)

// deg2rad * degrees = radians
#define deg2rad (3.14159265/180.0)
// rad2deg * radians = degrees
#define rad2deg (180/3.14159265)
share|improve this answer
radians = (degrees/360) * 2 * pi
share|improve this answer

Your Answer


