In MariaDB, RADIANS()
is a built-in function that returns its argument converted from degrees to radians.
The RADIANS()
function is the converse of the DEGREES()
function.
Syntax
The syntax goes like this:
RADIANS(X)
Where X
is the value, in degrees, that is to be converted to radians.
Example
Here’s an example:
SELECT RADIANS(30);
Result:
+--------------------+ | RADIANS(30) | +--------------------+ | 0.5235987755982988 | +--------------------+
Fractions
The argument can contain a fractional part:
SELECT RADIANS(125.34178);
Result:
+--------------------+ | RADIANS(125.34178) | +--------------------+ | 2.187626751310378 | +--------------------+
Negative Values
The argument can be negative:
SELECT RADIANS(-240);
Result:
+---------------------+ | RADIANS(-240) | +---------------------+ | -4.1887902047863905 | +---------------------+
Expressions
The argument can include expressions like this:
SELECT RADIANS(80 * 12);
Result:
+--------------------+ | RADIANS(80 * 12) | +--------------------+ | 16.755160819145562 | +--------------------+
Non-Numeric Arguments
Here’s an example of what happens when we provide a non-numeric argument:
SELECT RADIANS('Cat');
Result:
+----------------+ | RADIANS('Cat') | +----------------+ | 0 | +----------------+ 1 row in set, 1 warning (0.001 sec)
Let’s see the warning:
SHOW WARNINGS;
Result:
+---------+------+-----------------------------------------+ | Level | Code | Message | +---------+------+-----------------------------------------+ | Warning | 1292 | Truncated incorrect DOUBLE value: 'Cat' | +---------+------+-----------------------------------------+
Null Arguments
RADIANS()
returns null
if the argument is null
:
SELECT RADIANS(null);
Result:
+---------------+ | RADIANS(null) | +---------------+ | NULL | +---------------+
Missing Arguments
Calling RADIANS()
with the wrong number of arguments, or without any arguments results in an error:
SELECT RADIANS();
Result:
ERROR 1582 (42000): Incorrect parameter count in the call to native function 'RADIANS'
And:
SELECT RADIANS(10, 2);
Result:
ERROR 1582 (42000): Incorrect parameter count in the call to native function 'RADIANS'