Function
ROUND
rounds the passed value using standard Math rules.
The first argument
2.3
will be rounded to 2 and the second
2.5
becomes 3
SELECT
ROUND(2.3),
ROUND(2.5)
Function
FLOOR
rounds the argument down to the greater integer less then the decimal argument.
Both of the arguments will be rounded down to
2
SELECT
FLOOR(2.3),
FLOOR(2.8)
Function
CEIL
rounds the number up to the lowest integer value greater than the passed decimal argument.
Both of the arguments will be rounded to
3
SELECT
CEIL(2.3),
CEIL(2.8)
Function
RADIANS
converts degrees to radians.
90
degrees converted to radians gives us half of
PI
:
1.5707963267948966
.
180
degrees converted to radians gives us
PI
:
3.141592653589793
.
SELECT
RADIANS(90),
RADIANS(180)
Function
DEGREES
converts radians back to degrees.
Half of
PI
radians
1.5707963267948966
converted to degrees gives us
90
degrees.
PI
:
3.141592653589793
radians converted to degrees gives us
180
degrees.
SELECT
DEGREES(1.5707963267948966),
DEGREES(3.141592653589793)
These two functions
RADIANS
and
DEGREES
are opposite to each other.
180
degrees converted to radians gives us
PI
:
3.141592653589793
PI
:
3.141592653589793
radians converted to degrees gives us
180
degrees.
SELECT
RADIANS(180),
DEGREES(3.141592653589793)
Function
POWER
raises the first argument to the power of another argument.
The code below returns
16
because
2
to the power of
4
is
16
SELECT
POWER(2, 4)
Note:
POW
and
POWER
are the aliases for the same command
The function
CONV
converts the first argument from one number system (the second argument) to another (the third argument)
Converts
5
from
10
base system to
2
SELECT
CONV(5, 10, 2)
Complete list of mathematical functions on the official documentation: https://dev.mysql.com/doc/refman/8.0/en/mathematical-functions.html