Math Functions and Operators¶
- abs(number int|float)¶
Returns absolute value
Parameters: number – input number Return type: same as a parameter type Example: select abs(-9); > 9
- acos(number float)¶
Returns the arc cosine of number value
Parameters: number – input number as radian Return type: float8 Example: select acos(0.3); > 1.2661036727794992
- asin(number float)¶
Returns the arc sine of number value
Parameters: number – input number as radian Return type: float8 Example: select acos(0.8); > 0.9272952180016123
- atan(number float8)¶
Returns the arc tangent of number value
Parameters: number – input number as radian Return type: float8 Example: select atan(0.8); > 0.6747409422235527
- atan2(y float, x float)¶
Returns the angle theta from the conversion of rectangular coordinates (x, y) to polar coordinates (r, theta)
Parameters: - y – the ordinate(y axis) coordinate
- x – the abscissa(x axis) coordinate
Return type: float8
Example: select atan2(2.7, 0.3); > 1.460139105621001
- cbrt(number float)¶
Returns the cube root of a number
Parameters: number – target real number Return type: float8 Example: select cbrt(27.0); > 3.0
- ceil(number float)¶
Returns a smallest integer not less than argument
Parameters: number – target real number Return type: int8 Alias: ceiling Example: select ceil(-42.8); > -42
- cos(number float)¶
Returns the cosine of a number
Parameters: number – target real number Return type: float8 Example: select cos(0.7); > 0.7648421872844885
- degrees(number float)¶
Converts radians to degrees
Parameters: number – radian value Return type: float8 Example: select degrees(0.8); > 45.83662361046586
- div(num1 int, num2 int)¶
Integer division truncates resut
Parameters: - num1 – number to be divided
- num2 – number to divide
Return type: int8
Example: select div(8,3); > 2
- exp(number float)¶
Returns Euler’s number e raised to the power of a number
Parameters: number – input number Return type: float8 Example: select exp(1.0); > 2.718281828459045
- floor(number float)¶
Returns a largest integer not greater than argument
Parameters: number – target real number Return type: int8 Example: select floor(53.1); > 53
- mod(num1 int, num2 int)¶
Returns remainder of num1 / num2
Parameters: - num1 – number to be divided
- num2 – number to divide
Return type: int8
Example: select mod(10,3); > 1
- pi()¶
Returns constant value of pi
Return type: float8 Example: select pi(); > 3.141592653589793
- pow(x float, y float)¶
Returns value of x raised to the power of y
Parameters: - x – base number
- y – exponent
Return type: float8
Example: select pow(2.0, 10.0); > 1024.0
- radians(number float)¶
Converts degrees to radians
Parameters: number – degree value Return type: float8 Example: select radians(45.0); > 0.7853981633974483
- random(number int4)¶
Returns a pseudorandom number.
Parameters: number – range restriction Return type: int4 Example: select random(10); > 4
- round(number int|float)¶
Rounds to nearest integer
Parameters: number – target number Return type: int8 Example: select round(5.1); > 5
- sign(number int|float)¶
Returns sign of argument as -1, 0, 1
Parameters: number – target number Return type: float8 Example: select sign(-8.4); > -1.0
- sin(number float)¶
Returns the sine of number value
Parameters: number – target number Return type: float8 Example: select sin(1.0); > 0.8414709848078965
- sqrt(number float8)¶
Returns the square root of a number
Parameters: number – target number Return type: float8 Example: select sqrt(256.0); > 16.0
- tan(number float)¶
Returns the tangent of number value
Parameters: number – target number Return type: float8 Example: select tan(0.2); > 0.2027100355086725