MySQL Numeric Functions

MySQL provides various built-in Mathematical or Numeric functions, and trigonometric functions to perform different operations on numerical data. In this study, we show you the list of MySQL Numeric functions and Trigonometric functions with an example of each one of them.

MySQL Numeric Functions

The following are the list of MySQL Mathematical and Trigonometric functions that are available to work with numerical data.

MySQL Numeric FunctionsDescription
ABS()This returns the absolute positive value
ACOS()This MySQL Numeric function returns the Arc cosine value.
ASIN()This MySQL Trigonometric function returns the Arc Sine
 ATAN()It returns the Arc Tangent value.
ATAN2()Return the Arctangent value of two arguments.
CEIL()It returns the smallest integer value which is not less than the given value.
CEILING()Return the smallest integer not less than a given value.
CONV()Convert the given number between different base numbers.
COS()This MySQL Numeric function returns the Cosine of a given value.
COT()Returns the Cotangent value
CRC32()Cyclic redundancy check value.
DEGREES()It converts the radians value to Degrees
EXP()Raise to the power of
FLOOR()It returns the largest integer value which is not greater than the given value.
LN()Synonym for the MySQL LOG function
LOG()Returns the natural logarithmic value.
LOG10()This MySQL Numeric function returns the logarithmic base 10 value of the given argument.
LOG2()Returns the logarithmic base 2 value
MOD()Returns the remainder.
PIUse this to get PI value (3.14)
POW()It returns the argument raised to the specified power.
POWER()Finds the given value raised to the specified power.
RADIANS()It converts the Degrees value to radians
RAND()It retunes the random float value.
ROUND()This MySQL Numeric function rounds the given value.
SIGN()It returns the sign (positive, negative) of the argument
SIN()Returns the Sine Value of the given argument.
SQRT()Finds the square root of a given value
TAN()Returns the Tangent Value
TRUNCATE()It truncates the given value to user specified decimal places.

MySQL Numeric Functions Examples

The following examples help you to understand these mathematical functions in MySQL

MySQL Trigonometric Functions Example 1

In this example, we are going to use MySQL ABS function to find the absolute positive value. Next, we used MySQL ACOS, ASIN functions to find the Arc cosine, and Arc Sine values.

SELECT ABS(10), ABS(-32), ABS(-44), ABS(-23.32);

SELECT ACOS(1), ACOS(0), ACOS(0.5), ACOS(0.75);

SELECT ASIN(0), ASIN(0.25), ASIN(0.50), ASIN(1);
MySQL Numeric Functions 1

MySQL Trigonometric Functions Example 2

In this MySQL Trigonometric functions example, we are going to use the ATAN and ATAN2 functions to find the Arctangent value of single and double arguments. Next, we used the COS function to find Cosine value.

SELECT ATAN(4), ATAN(24), ATAN(-32);

SELECT ATAN2(1, 5), ATAN2(-2, 3), ATAN(3.5, 0);

SELECT COS(0), COS(1), COS(2.5), COS(0.25);
MySQL Numeric Functions 2

MySQL Numeric Functions Example 3

In this example, we are going to use the MySQL CEIL, CEILING function to find the closest value. Next, we applied the CONV function to convert the given value based on the given base.

SELECT CEIL(1.25), CEIL(1.95), CEIL(-2.3), CEIL(-2.90);


SELECT CONV('A', 16, 2), CONV('G', 18, 8);
MySQL Numeric Functions 3

MySQL Numeric Functions Example 4

In this instance, we are going to use the MySQL COT, DEGREES, and EXP functions.

SELECT COT(5), COT(1), COT(15);


SELECT EXP(0), EXP(2), EXP(-2);
MySQL Numeric Functions 4

MySQL Mathematical Functions Example 5

In this MySQL Mathematical functions example, we are going to apply the EXP, FLOOR, and FORMAT functions.

SELECT EXP(0), EXP(2), EXP(-2);

SELECT FLOOR(2.89), FLOOR(2.05), FLOOR(-2.25), FLOOR(-2.97);

SELECT FORMAT(543212.1245, 2), FORMAT(1121343.87965, 4);
MySQL Numeric Functions 5

MySQL Mathematical Functions Example 6

In this MySQL Mathematical functions example, we are going to practice the LN, LOG, LOG2 functions to find the Natural Logarithmic Value, and Log base 2 value.

SELECT LN(2), LN(5), LN(-5);

SELECT LOG(2), LOG(2, 250), LOG(10, 250);

SELECT LOG2(250), LOG2(24567), LOG2(-23234);
MySQL Numeric Functions 6

MySQL Numeric Functions Example 7

Here, we are going to use the MySQL LOG10 function to find the Logarithmic value of base 10. Next, MySQL MOD to find the remainder, and PI function to get the PI value.

SELECT LOG10(250), LOG10(1000), LOG10(2500);

SELECT MOD(250, 7), MOD(59, 9), 600 MOD 16;

MySQL Numeric Functions 7

MySQL Mathematical Functions Example 8

In this MySQL Mathematical functions example, we use the POWPOWER functions to find the Power. Next, we applied MySQL RADIANS to convert Degrees to radians.

SELECT POW(3, 2), POW(25, 5), POW(16, 2);

SELECT POWER(3, 2), POWER(25, 5), POWER(16, 2);

MySQL Numeric Functions 8

MySQL Mathematical Functions Example 9

In this MySQL Mathematical functions example, we are going to use the RAND to return random value, SIGN function to find the sign. Next, we used the MySQL ROUND function to round the decimals.


SELECT ROUND(-12.25), ROUND(-12.67), ROUND(14.268, 1);

SELECT SIGN(-12), SIGN(12), SIGN(0);
MySQL Numeric Functions 9

MySQL Numeric Functions Example 10

In this instance, we are going to use the MySQL SIN, TAN function to find the Sine Value, Tangent Value. Next, we used the MySQL SQRT function to find the square root of a given value.

SELECT SIN(0), SIN(2.5), SIN(1);

SELECT TAN(3.14), TAN(1), TAN(0);

SELECT SQRT(16), SQRT(25), SQRT(894);
MySQL Numeric Functions 10

Numeric Functions Example 11

We are going to use MySQL TRUNCATE and HEX functions.

SELECT TRUNCATE(10.9876, 1), TRUNCATE(10.9876, 0);

SELECT HEX(255), HEX('Hi'), HEX('Hello');
MySQL Numeric Functions 11