TurboSQL Guide Arithmetic Functions and Operators |
Previous Top Next |
This is a list of arithmetic functions and operators that can be used in TurboSQL.
+
Syntax
value1 + value2
Description
Calculates the sum of two numbers.
-
Syntax
value1 - value2
Description
Calculates the difference of two numbers.
*
Syntax
value1 * value2
Description
Calculates the product of two numbers.
/
Syntax
value1 / value2
Description
Calculates the quotient of two numbers.
%
Syntax
value1 % value2
Description
Calculates the modulo of two integral numbers.
Compatibility Information
This operator is only available in TurboDB Managed.
ARCTAN
Syntax
ARCTAN(value)
Description
Calculates the arcus tangens of value.
CEILING
Syntax
CEILING(value)
Description
Calculates the smallest integral number greater than, or equal to, the given value.
Example
CEILING(-3.8) --returns -3.0
CEILING(3.8) --returns 4.0
COS
Syntax
COS(value)
Description
Calculates the cosine of value.
DIV
Syntax
a div b
Description
Integer division
Example
35 div 6 --returns 5
-35 div 6 --returns -5
35 div -6 --returns -5
-35 div -6 --returns 5
EXP
Syntax
EXP(:X DOUBLE) RETURNS DOUBLE
Description
Calculates the exponential of value (to base e)
FLOOR
Syntax
FLOOR(:X DOUBLE) RETURNS DOUBLE
Description
Calculates the largest integral number less than or equal to the given value.
Example
FLOOR(-3.8) --returns -4.0
FLOOR(3.8) --returns 3.0
FRAC
Syntax
FRAC(:X DOUBLE) RETURNS DOUBLE
Description
Calculates the fractional part of real number.
Example
FRAC(-3.8) --returns -0.8
FRAC(3.8) --returns 0.8
INT
Syntax
INT(:X DOUBLE) RETURNS BIGINT
Description
Calculates the integral part of a real number as an integer number.
Example
INT(-3.8) --returns -3
INT(3.8) --returns 3
LOG
Syntax
LOG(:X DOUBLE) RETURNS BIGINT
Description
Calculates the natural logarithm of a real number.
MOD
Syntax
a mod b
Description
Remainder of the integer division. a mod b = a - (a div b) * b always holds.
Example
35 mod 6 --returns 5
35 mod -6 --returns 5
-35 mod 6 --returns 5
-35 mod -6 --returns 5
ROUND
Syntax
ROUND(:X DOUBLE [, :Precision BYTE]) RETURNS DOUBLE
Description
Rounds the value to the given number of digits.
Compatibility Information
This function is only available in TurboDB Win.
Example
ROUND(3.141592, 3) --returns 3.142
SIN
Syntax
SIN(:X DOUBLE) RETURNS DOUBLE
Description
Calculates the sine of a value.
SQRT
Syntax
SQRT(:X DOUBLE) RETURNS DOUBLE
Description
Calculates the square root of a value.
See also
General Functions and Operators
Arithmetic Functions and Operators
String Functions and Operators
Date and Time Functions and Operators
Aggregation Functions
Miscellaneous Functions and Operators