In MySQL, the RADIANS()
function converts a value from degrees to radians, and returns the result.
You provide the value in degrees as an argument when calling the function.
Syntax
The syntax goes like this:
RADIANS(X)
Where X
is the value for which you’d like to have converted from degrees to radians.
Example 1 – Basic Usage
Here’s a basic example.
SELECT RADIANS(75);
Result:
+--------------------+ | RADIANS(75) | +--------------------+ | 1.3089969389957472 | +--------------------+
And here’s another example using a different value.
SELECT RADIANS(1);
Result:
+----------------------+ | RADIANS(1) | +----------------------+ | 0.017453292519943295 | +----------------------+
Example 2 – Negative Values
Swapping the previous number to a negative value produces a negative result.
SELECT RADIANS(-1);
Result:
+-----------------------+ | RADIANS(-1) | +-----------------------+ | -0.017453292519943295 | +-----------------------+
Example 3 – Expressions
You can also pass in expressions like this:
SELECT RADIANS(20000 / 4);
Result:
+--------------------+ | RADIANS(20000 / 4) | +--------------------+ | 87.26646259971648 | +--------------------+
Example 4 – Zero
Obviously, passing in zero will result in zero.
SELECT RADIANS(0);
Result:
+------------+ | RADIANS(0) | +------------+ | 0 | +------------+
Example 5 – NULL
And passing in NULL
returns NULL
.
SELECT RADIANS(NULL);
Result:
+---------------+ | RADIANS(NULL) | +---------------+ | NULL | +---------------+
Example 6 – Strings
And passing in a string results in zero.
SELECT RADIANS('Cat');
Result:
+----------------+ | RADIANS('Cat') | +----------------+ | 0 | +----------------+
Convert From Radians to Degrees
If you need to convert the other way, see MySQL DEGREES() Function – Convert From Radians to Degrees.