Mathematical Functions
This topic describes the mathematical functions supported by StoneDB.
Function | Description | Example |
---|---|---|
ABS(x) | Returns the absolute value. | SELECT ABS(-1); ->1 |
ACOS(x) | Returns the arc cosine of numeral value x. | SELECT ACOS(0.5); ->1.0471975511965979 |
ASIN(x) | Returns the arc sine of numeral value x. | SELECT ASIN(0.5); ->0.5235987755982989 |
ATAN(x) | Returns the arc tangent of numeral value x. | SELECT ATAN(2.5); ->1.1902899496825317 |
ATAN2(n, m) | Returns the arc tangent of two numeral values. | SELECT ATAN2(1,2); ->0.4636476090008061 |
COS(x) | Returns the cosine of radian x. | SELECT COS(2); ->-0.4161468365471424 |
COT(x) | Returns the cotangent of radian x. | SELECT COT(2); ->-0.45765755436028577 |
TAN(x) | Returns the tangent of radian x. | SELECT TAN(45); ->1.6197751905438615 |
SIN(x) | Returns the sine of radian x. | SELECT SIN(RADIANS(30)); ->0.49999999999999994 |
CEIL(x) CEILING(x) | Returns the smallest integer value that is not smaller than x. | SELECT CEIL(4.19); ->5 |
DEGREES(x) | Converts radian x to a degree. | SELECT DEGREES(3.1415926535898); ->180.0000000000004 |
EXP(x) | Returns the natural exponential of x. | SELECT EXP(2); ->7.38905609893065 |
FLOOR(x) | Returns the largest integer value that is not greater than x. | SELECT FLOOR(3.24); ->3 |
GREATEST(expr1, expr2, expr3, ...) | Returns the greatest value within the specified list. | SELECT GREATEST(79,36,3,8,1); ->79 SELECT GREATEST('Hello','CHINA','STONEDB'); ->STONEDB |
LEAST(expr1, expr2, expr3, ...) | Returns the smallest value within the specified list. | SELECT LEAST(79,36,3,8,1); ->1 SELECT LEAST('Hello','CHINA','STONEDB'); ->CHINA |
LN(x) | Returns the natural logarithm of x. | SELECT LN(3); ->1.0986122886681098 |
LOG(x,y) | Returns the base-x logarithm of_ y_. | SELECT LOG(3,81); ->4 |
LOG2(x) | Returns the base-2 logarithm of_ x_. | SELECT LOG2(64); ->6 |
PI() | Returns the value of pi. | SELECT PI(); ->3.141593 |
POW(x,y), POWER(x,y) | Returns x raised to the specified power of y. | SELECT POW(2,4); ->16 |
RAND() | Returns a random number between 0 and 1. | SELECT RAND(); ->0.12216221831940322 |
ROUND(x) | Returns the value of x rounded to the nearest integer. | SELECT ROUND(-5.26); ->-5 |
SIGN(x) | Returns the sign of x. - If x is a negative value, -1 is returned. - If_ x_ is 0, 0 is returned. - If x is a positive value, 1 is returned. | SELECT SIGN(-10); ->(-1) |
SQRT(x) | Returns the square root of x. | SELECT SQRT(81); ->9 |
TRUNCATE(x,y) | Truncates x to retain y decimal places. | SELECT TRUNCATE(2.2849106,3); ->2.284 |