tencent cloud

Feedback

Arithmetic Functions

Last updated: 2023-11-08 14:19:38
Arithmetic functions are described as follows:
Function
Description
+numeric
Returns the value of numeric itself.
-numeric
Returns the negative value of numeric.
numeric1 + numeric2
Returns numeric1 plus numeric2.
numeric1 - numeric2
Returns numeric1 minus numeric2.
numeric1 * numeric2
Returns numeric1 multiplied by numeric2.
numeric1 / numeric2
Returns numeric1 divided by numeric2.
POWER(numeric1, numeric2)
Returns numeric1 raised to the power of numeric2.
ABS(numeric)
Returns the absolute value of numeric.
MOD(numeric1, numeric2)
Returns the remainder of numeric1 divided by numeric2. The result is negative if numeric1 is negative.
SQRT(numeric)
Returns the square root of numeric.
LN(numeric)
Returns the natural logarithm (base e) of numeric.
LOG10(numeric)
Returns the base 10 logarithm of numeric.
LOG2(numeric)
Returns the base 2 logarithm of numeric.
LOG(numeric2) LOG(numeric1, numeric2)
When called with one parameter, returns the natural logarithm of numeric2 (equivalent to LN). When called with two parameters, returns the logarithm of numeric2 to the base numeric1.
EXP(numeric)
Returns e raised to the power of numeric.
CEIL(numeric) CEILING(numeric)
Returns the smallest integer value that is larger than or equal to numeric.
FLOOR(numeric)
Returns the largest integer value that is less than or equal to numeric.
TRUNCATE(numeric1, numeric2)
Returns numeric1 truncated to numeric2 decimal places.
Returns NULL if any parameter is NULL.
If numeric2 is 0 or left empty, the result has no decimal point or fractional part. numeric2 can be negative to cause numeric2 digits left of the decimal point of the value to become zero. For example, TRUNCATE(42.345, 2) returns 42.34, TRUNCATE(42.345) returns 42.0, and TRUNCATE(42.345, -1) returns 40.0.
SIN(numeric)
Returns the sine of numeric.
SINH(numeric)
Returns the hyperbolic sine of numeric. The return value is of DOUBLE type.
COS(numeric)
Returns the cosine of numeric.
COSH(numeric)
Returns the hyperbolic cosine of numeric. The return value is of DOUBLE type.
TAN(numeric)
Returns the tangent of numeric.
TANH(numeric)
Returns the hyperbolic tangent of numeric. The return value is of DOUBLE type.
COT(numeric)
Returns the cotangent of numeric.
ASIN(numeric)
Returns the arc sine of numeric.
ACOS(numeric)
Returns the arc cosine of numeric.
ATAN(numeric)
Returns the arc tangent of numeric.
ATAN2(numeric1, numeric2)
Returns the arc tangent of a coordinate (numeric1, numeric2).
DEGREES(numeric)
Returns the degree representation of a radian numeric.
RADIANS(numeric)
Returns the radian representation of a degree numeric.
SIGN(numeric)
Returns the signum of numeric. Returns -1 for a negative number, 0 for 0, and 1 for a positive number.
ROUND(numeric, int)
Returns a number rounded to int decimal places for numeric.
PI()
Returns a value that is closer than any other values to pi.
E()
Returns a value that is closer than any other values to e.
RAND() RAND(seed value)
Returns a pseudorandom value in the range [0.0, 1.0). You can specify an integer as the seed value.
RAND_INTEGER(upper limit) RAND_INTEGER(seed value, upper limit)
Returns a pseudorandom value in the range [0.0, upper limit).
UUID()
Returns a Universally Unique Identifier (UUID) string according to type 4 (pseudo randomly generated) UUID.
LOG(numeric) LOG(base, numeric)
Returns the natural logarithm of numeric or the logarithm of numeric·to base.
BIN(numeric)
Returns a string representation of numeric in binary format. For example, BIN(4) returns "100".
HEX(numeric) HEX(string)
Returns a string representation of numeric or string in hex format. For example, HEX(15) or HEX("15") returns "F".

Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

7x24 Phone Support