原文地址:https://www.mysqltutorial.org/mysql-math-functions/
This page explores the most frequently used MySQL math functions with practical & real-world examples.
Name | Description |
---|---|
ABS() | Returns the absolute value of a number |
CEIL() | Returns the smallest integer value greater than or equal to the input number (n). |
FLOOR() | Returns the largest integer value not greater than the argument |
MOD() | Returns the remainder of a number divided by another |
ROUND() | Rounds a number to a specified number of decimal places. |
TRUNCATE() | Truncates a number to a specified number of decimal places |
ACOS(n) | Returns the arc cosine of n or null if n is not in the range -1 and 1. |
ASIN(n) | Returns the arcsine of n which is the value whose sine is n. It returns null if n is not in the range -1 to 1. |
ATAN() | Returns the arctangent of n. |
ATAN2(n,m), ATAN(m,n) | Returns the arctangent of the two variables n and m |
CONV(n,from_base,to_base) | Converts a number between different number bases |
COS(n) | Returns the cosine of n, where n is in radians |
COT(n) | Returns the cotangent of n. |
CRC32() | Computes a cyclic redundancy check value and returns a 32-bit unsigned value |
DEGREES(n) | Converts radians to degrees of the argument n |
EXP(n) | Raises to the power of e raised to the power of n |
LN(n) | Returns the natural logarithm of n |
LOG(n) | Returns the natural logarithm of the first argument |
LOG10() | Returns the base-10 logarithm of the argument |
LOG2() | Returns the base-2 logarithm of the argument |
PI() | Returns the value of PI |
POW() | Returns the argument raised to the specified power |
POWER() | Returns the argument raised to the specified power |
RADIANS() | Returns argument converted to radians |
RAND() | Returns a random floating-point value between 0 and 1. |
SIGN(n) | Returns the sign of n that can be -1, 0, or 1 depending on whether n is negative, zero, or positive. |
SIN(n) | Returns the sine of n |
SQRT(n) | Returns the square root of n |
TAN(n) | Returns the tangent of n |