Mysql Math functions

What are the Math Functions in Mysql?

Explanation

MySQL Math Functions :


DEGREES(X) :
This function returns the argument X, converted from radians to degrees.
mysql> select degrees(pi());
--> 180
mysql> select degrees(0.78539816339745);
--> 45
EXP(X) :
Returns the value of the base of natural logarithms(e) raised to the power of X.
mysql> select exp(-1);
--> 0.36787944117144
mysql> select exp(1);
--> 2.718281828459
FLOOR(X) :
Returns the largest integer value not greater than X.
mysql> select floor(5.68);
--> 5
mysql> select floor(-1.26);
--> 2
FORMAT(X,D) :
Formats the given number in a ##,###.## format,rounded to D decimal places.
mysql> select format(7895423.23478,2);
--> 7,895,423.23
mysql> select format(1287654.458,0);
--> 1,287,654
LN(X) :
Returns the natural logarithm of X, the base-e logarithm of X.
mysql> select ln(3);
--> 1.0986122886681
mysql> select ln(-1);
--> NULL
LOG(X) :
This function returns the natural logarithm of X, if it contains a single parameter.
mysql> select log(1);
--> 0
mysql> select log(-2);
--> NULL
LOG(B,X) :
If it contains two parameters, then returns the natural logarithm of X for an arbitrary base B .
mysql> select log(3,4512);
--> 7.659204143237
mysql> select log(1,250);
--> NULL
Press next to learn more mysql math functions.


Ask Questions

Ask Question