Mathematical Functions
This page lists the mathematical functions that are available in the GSQL query language. They are divided into three categories:
General
Logarithmic
Trigonometric
General
abs()
Syntax
abs( num )
Description
Returns the absolute value of a number.
Return type
Number
Parameters
Parameter | Description | Data type |
| The number to return the absolute value for | Number |
ceil()
Syntax
ceil(num)
Description
Rounds a number up to the smallest integer that's greater than or equal to the number.
Return type
INT
Parameters
Parameter | Description | Data type |
| The number to round up from | num |
exp()
Syntax
exp(num)
Description
Returns the base-e exponential of a number.
Return type
FLOAT
Parameters
Parameter | Description | Data type |
| The exponent | Number |
float_to_int()
Syntax
float_to_int (num)
Description
Converts a floating-point number to an integer by truncating the floating part.
Return type
INT
Parameters
Parameter | Description | Data type |
| The floating-point number to convert to integer |
|
floor()
Syntax
floor(num)
Description
Rounds a number down to the biggest integer that is smaller than or equal to the number.
Return type
INT
Parameter
Parameter | Description | Data type |
| The number to round down from | Number |
fmod()
Syntax
fmod(numer, denom)
Description
Returns the floating-point remainder of numer
divided by denom
Return type
FLOAT
Parameters
Parameter | Description | Data type |
| The dividend | Number |
| The divisor | Number |
ldexp()
Syntax
ldexp(x, exp)
Description
Returns x
multiplied by 2 raised to the power of exp
Return type
FLOAT
Parameters
Parameter | Description | Data type |
| The base | Number |
| The exponent of 2 | Number |
PI()
Syntax
PI()
Description
Returns the value of π.
Return type
DOUBLE
Parameters
None.
Example
pow()
Syntax
pow(base, exp)
Description
Returns the power of a number.
Return type
FLOAT
Parameters
Parameter | Description | Data type |
| The base | Number |
| The exponent | Number |
rand()
Syntax
rand( [seed] )
Description
Returns a completely random number >= 0 and <1. If seed
is specified, it returns a repeatable sequence of random numbers. If no seed is specified, it returns a completely random number.
Return type
DOUBLE
Parameters
Parameter | Description | Data type |
| Optional. If |
|
Example
round()
Syntax
round ( num[, integer] )
Description
Rounds a number to a specified place relative to the decimal point and returns the result.
Return type
A numeric type.
Parameters
Parameter | Description | Data type |
| The number to be rounded |
|
| Optional. An integer value indicating the place to round the first argument to. If |
|
Examples
sign()
Syntax
sign( num )
Description
Returns the sign of a number. If the number is positive, return 1
; if the number is negative, return -1
; if the number is 0
, return 0
Return type
INT
Parameters
Parameter | Description | Data type |
| A numeric value |
|
Examples
square()
Syntax
square( num )
Description
Returns the square of a number.
Return type
A numeric type.
Parameters
Parameter | Description | Data type |
| A numeric value. |
|
Examples
sqrt()
Syntax
sqrt(num)
Description
Returns the square root of a number
Return type
FLOAT
Parameters
Parameter | Description | Data type |
| The number to get square root for. | Number |
trunc()
Syntax
trunc( num, [decimal_place] )
Description
Returns a number truncated to a specified decimal place.
Return type
A numeric type.
Parameters
Parameter | Description | Data type |
| The number to be truncated |
|
| Optional. The integer indicating the decimal place to truncate the number to.
If |
|
Examples
Logarithmic
log()
Syntax
log(num)
Description
Returns the natural logarithm of a number (base e).
Return type
DOUBLE
Parameters
Parameter | Description | Data type |
| The number to compute natural logarithm for | Number |
log2()
Syntax
log2( num )
Description
Returns the base-2 logarithm of a number.
Return type
DOUBLE
Parameters
Parameter | Description | Data type |
| A numeric value |
|
Examples
log10()
Syntax
log10(num)
Description
Return the common logarithm of a number (base 10).
Return type
FLOAT
Parameters
Parameter | Description | Data type |
| The number to compute common logarithm for | Number |
Trigonometric
acos()
Syntax
acos(num)
Description
Returns the arc cosine of a number.
Return type
FLOAT
Parameters
Parameter | Description | Data type |
| The number to compute arccosine for | Number |
asin()
Syntax
asin(num)
Description
Returns the arc sine of a number.
Return type
FLOAT
Parameters
Parameter | Description | Data type |
| The number to compute arcsine for | Number |
atan()
Syntax
atan(num)
Description
Returns the arctangent of a number.
Return type
FLOAT
Parameters
Parameter | Description | Data type |
| The number to compute arctangent for | Number |
atan2()
Syntax
atan2(y, x)
Description
Returns the arctangent of a fraction.
Return type
FLOAT
Parameters
Parameter | Description | Data type |
| The dividend of the fraction to compute arctangent for | Number |
| The divisor of the fraction to compute arctangent for | Number |
cos()
Syntax
cos(num)
Description
Returns the cosine of a number.
Return type
FLOAT
Parameters
Parameter | Description | Data type |
| The number to return cosine for | Number |
cosh()
Syntax
cosh(num)
Description
Returns the hyperbolic cosine of a number.
Return type
FLOAT
Parameters
Parameter | Description | Data type |
| The number to compute hyperbolic cosine for | Number |
cot()
Syntax
cot( num )
Description
Returns the cotangent of a number.
Return type
DOUBLE
Parameters
Parameter | Description | Data type |
| A numeric value |
|
Examples
degrees()
Syntax
degrees( num )
Description
Converts a value in radians to degrees.
Return type
DOUBLE
Parameters
Parameter | Description | Data type |
| A numeric value |
|
Examples
radians()
Syntax
radians( num )
Description
Converts a value in degrees to radians.
Return type
DOUBLE
Parameters
Parameter | Description | Data type |
| A numeric value |
|
Examples
sin()
Syntax
sin(num)
Description
Returns the sine of a number.
Return type
FLOAT
Parameters
Parameter | Description | Data type |
| The number to compute sine for | Number |
sinh()
Syntax
sinh(num)
Description
Returns the hyperbolic sine of a number.
Return type
FLOAT
Parameters
Parameter | Description | Data type |
| The number to compute hyperbolic sine for | Number |
tan()
Syntax
tan(num)
Description
Returns the tangent of a number.
Return type
FLOAT
Parameters
Parameter | Description | Data type |
| The number to compute tangent for | Number |
tanh()
Syntax
tanh(num)
Description
Returns the hyperbolic tangent of a number.
Return type
FLOAT
Parameters
Parameter | Description | Data type |
| The number to compute hyperbolic tangent for | Number |
Last updated