MariaDB PI() Function
The MariaDB PI()
function returns the value of π (pi) with 6 decimal places.
The number π is a mathematical constant. It is defined as the ratio of the circumference of a circle to its diameter, and it also has various equivalent definitions. It is approximately equal to 3.141593, but it is an infinite non-repeating decimal.
Please refer DEGREES()
and RADIANS()
.
MariaDB PI()
Syntax
Here is the syntax of the MariaDB PI()
function:
PI()
Parameters
The MariaDB PI()
function does not accept any arguments.
If you supply the wrong number of arguments, MariaDB will report an error: ERROR 1582 (42000): Incorrect parameter count in the call to native function 'PI'
.
Return value
The MariaDB PI()
function returns the value of π (pi) with 6 decimal places.
While the PI()
function returns a PI value with 6 decimal places. However, MariaDB internally maintains a double precision value.
MariaDB PI()
Examples
Example 1 - Basic usage
To return a PI value with 6 decimal places, use the PI()
function:
SELECT PI();
Output:
+----------+
| PI() |
+----------+
| 3.141593 |
+----------+
Example 2 - Return more decimal places
While the PI()
function returns a PI value with 6 decimal places. However, MariaDB internally maintains a double precision value.
SELECT
PI(),
PI() + 0.000000000000000,
PI() * 10000000000000000\G
Output:
PI(): 3.141593
PI() + 0.000000000000000: 3.141592653589793
PI() * 10000000000000000: 31415926535897932.0000
Example 3 - DEGREES()
Radian π represents a semicircle, and the MariaDB DEGREES()
function can convert radians to degrees.
SELECT DEGREES(PI());
Output:
+---------------+
| DEGREES(PI()) |
+---------------+
| 180 |
+---------------+
Example 4 - RADIANS()
MariaDB RADIANS()
function can convert degrees to radians:
SELECT RADIANS(180);
Output:
+-------------------+
| RADIANS(180) |
+-------------------+
| 3.141592653589793 |
+-------------------+
Summarize
The MariaDB PI()
function returns the value of π (pi) with 6 decimal places.