MySQL DEGREES() Function
MySQL DEGREES() Function: Converting Radians into Degrees
The DEGREES() function converts an angle measured in radians into degrees. Internally, MySQL multiplies the input by 180 / PI() and returns a DOUBLE value.
All trigonometric functions in MySQL—such as ASIN(), ACOS(), and ATAN2()—output angles in radians. Wrapping those results in DEGREES() turns raw math output into readable compass headings or UI labels.
Syntax
DEGREES(x)
x: Any numeric value or expression representing an angle in radians.
Practical Example
Suppose demo_employees stores robotics calibration offsets (tilt_radians) recorded by warehouse sensors. Technicians read angles in degrees, not radians, so your reporting query can display both the raw sensor reading and a clean rounded degree angle.
SELECT
employee_id,
station_code,
tilt_radians,
ROUND(DEGREES(tilt_radians), 2) AS tilt_degrees
FROM demo_employees
WHERE station_code IS NOT NULL;
| employee_id | station_code | tilt_radians | tilt_degrees |
|---|---|---|---|
| 14 | BAY-A | 0.785398 | 45.00 |
| 15 | BAY-B | 1.570796 | 90.00 |
| 16 | BAY-C | -3.141593 | -180.00 |
| 17 | BAY-D | NULL | NULL |
Row 14 converts PI() / 4 radians cleanly into 45.00 degrees, while row 16 converts -PI() into -180.00 degrees. Row 17 has no calibration value yet, so DEGREES() returns NULL.
Common Mistakes & NULL Behavior
- Passing values already in degrees: Calling
DEGREES(90)multiplies90by57.2958, giving5156.62. Check unit labels before converting. - Tiny floating-point leftovers: Because
PI()is approximate in IEEE 754DOUBLE, expressions likeDEGREES(ACOS(-0.5))may yield120.00000000000001. ApplyROUND(..., 2)when formatting reports. - NULL inputs: Passing
NULLtoDEGREES(NULL)returnsNULL.
Frequently Asked Questions
What is the inverse of DEGREES() in MySQL?
Use RADIANS(x) to convert degrees back into radians before calling SIN(), COS(), or TAN().
Does DEGREES() accept negative radians?
Yes. Negative radian angles convert directly to negative degree angles, such as DEGREES(-PI() / 2) returning -90.
What does DEGREES(2 * PI()) return?
It returns 360, representing one full circle rotation in degrees.
Unlock Your
Full Potential.
Sign in to track your learning journey, earn industry-recognized certificates, and join our elite developer community.
Quick Access With
Try it Yourself
Experiment with the code from this lesson in our interactive playground.