Skip to main content

Mathematical functions and operators

Mathematical operators

OperatorExpression & DescriptionExample
+operand1 + operand2
Addition.
1 + 2 → 3
-operand1 - operand2
Subtraction.
1 - 2 → -1
-- operand
Negation.
- (-1) → 1
*operand1 * operand2
Multiplication.
2 * 3 → 6
/operand1 / operand2
Division (results are truncated for integers).
3 / 2 → 1
3.0 / 2 → 1.5
3 / 1.8 → 1.666
%operand1 % operand2
Remainder (valid for smallint/int/bigint/numeric).
3 % 2 → 1
^operand1 ^ operand2
Exponent.
2.0 ^ -2 → 0.25
||/||/ operand
Cube root.
||/ 27 → 3
@@ operand
Absolute value.
@ -10 → 10
&operand1 & operand2
Bitwise AND
91 & 15 → 11
|operand1 | operand2
Bitwise OR
32 | 3 → 35
#operand1 # operand2
Bitwise exclusive OR
17 # 5 → 20
~~ operand
Bitwise NOT
~1 → -2
<<operand1 << operand2
Bitwise shift left
1 << 4 → 16
>>operand1 >> operand2
Bitwise shift right
8 >> 2 → 2

Mathematical functions

FunctionDescriptionExample
abs ( input_value ) → absolute_value
@ ( input_value ) → absolute_value
Returns the absolute value of input_value. The input_value can be type int or decimal. The return type is the same as the input_value type.abs(-3) → 3
@(-3) → 3
cbrt ( double_precision_input ) → double_precision_outputReturns the cube root of the input.cbrt(27) → 3
ceil ( numeric_input ) → integer_output
ceil ( double_precision_input ) → integer_output
Returns the nearest integer greater than or equal to the argument. ceiling() can also be used as an alias for ceil().ceil(1.23559) → 2
ceiling(-1.23559) → -1
exp ( double_precision_input ) → double_precision_output
exp ( numeric_input ) → numeric_output
Returns the exponential value of numeric.exp(2.0) → 7.38905609893065
floor ( numeric_input ) → integer_output
floor ( double_precision_input ) → integer_output
Returns the nearest integer less than or equal to the argument.floor(1.23559) → 1
floor(-1.23559) → -2
ln ( double_precision_input ) → double_precision_output
ln ( numeric_input ) → numeric_output
Returns the natural logarithmic value of the input.ln(10) → 2.302585092994046
log10 ( double_precision_input ) → double_precision_output
log10 ( numeric_input ) → numeric_output
Returns the log base 10 value of the input value. log() can also be used and accepts the same input types.log10(25) → 1.3979400086720377
min_scale ( numeric_input ) → integer_outputMinimum scale (number of fractional decimal digits) needed to represent the supplied value preciselymin_scale(8.4100) → 2
pow ( x_double_precision, y_double_precision ) → double_precision
pow ( x_numeric, y_numeric ) → numeric
Returns x_double_precision or x_numeric raised to the power of y_double_precision or y_numeric. power() can also be used as an alias for pow().pow(2.0, 3.0) → 8
power(2.0, 3.0) → 8
round ( x_numeric, y_int ) → output_valueRounds x_numeric to y_int decimal places. y_int can be negative.round(1.23559, 2) → 1.24
round ( numeric_input ) → integer_output
round ( double_precision_input ) → integer_output
Rounds to the nearest integer.round(1.23559) → 1
scale ( numeric_input ) → integer_outputScale of the argument (the number of decimal digits in the fractional part)scale(8.4100) → 4
sign(double_precision_input or decimal_input) -> same_as_inputReturns the sign of the input value as -1 if the input is negative, 1 if the input is positive, or 0 if the input is 0.sign(8.64) → 1
sign(-8.64) → -1
sqrt ( numeric_input ) → numeric_output
sqrt ( double_precision_input ) → double_precision_output
Returns the square root of the input.sqrt(16) → 4
trim_scale ( numeric_input ) → numeric_outputReduces the value's scale (number of fractional decimal digits) by removing trailing zeroestrim_scale(8.4100) → 8.41
trunc ( double_precision_input ) → double_precision_output
trunc ( numeric_input ) → numeric_output
Truncate the input value to zero decimal places.trunc(-20.0932) → -20

Trigonometric functions

FunctionDescriptionExample
sin ( radians ) → sineReturns the trigonometric sine (in double precision) of an angle measured in radians (in double precision).sin(1) → 0.8414709848078965
cos ( radians ) → cosineReturns the trigonometric cosine (in double precision) of an angle measured in radians (in double precision).cos(1) → 0.5403023058681398
tan ( radians ) → tangentReturns the trigonometric tangent (in double precision) of an angle measured in radians (in double precision).tan(1) → 1.5574077246549021
cot ( radians ) → cotangentReturns the trigonometric cotangent (in double precision) of an angle measured in radians (in double precision).cot(1) → 0.6420926159343308
asin ( input_value ) → radiansReturns the inverse sine (in radians and double precision) of a given value (in double precision).asin(0.5) → 0.5235987755982989
acos ( input_value ) → radiansReturns the inverse cosine (in radians and double precision) of a given value (in double precision).acos(0.5) → 1.0471975511965976
atan ( input_value ) → radiansReturns the inverse tangent (in radians and double precision) of a given value (in double precision).atan(1.0) → 0.7853981633974483
atan2 ( y_value, x_value ) → radiansReturns the inverse tangent (in radians and double precision) of the quotient of two given values (y_value divided by x_value).atan2(1.0, 1.0) → 0.7853981633974483
sinh ( input_value ) → hyperbolic_sineReturns the hyperbolic sine (in double precision) of a given value (in double precision).sinh(1.0) → 1.1752011936438014
cosh ( input_value ) → hyperbolic_cosineReturns the hyperbolic cosine (in double precision) of a given value (in double precision).cosh(1.0) → 1.5430806348152437
tanh ( input_value ) → hyperbolic_tangentReturns the hyperbolic tangent (in double precision) of a given value (in double precision).tanh(1.0) → 0.7615941559557649
coth ( input_value ) → hyperbolic_cotangentReturns the hyperbolic cotangent (in double precision) of a given value (in double precision).coth(2) → 1.0373147207275481
asinh ( input_value ) → inverse_hyperbolic_sineReturns the inverse hyperbolic sine (in double precision) of a given value (in double precision).asinh(1.0) → 0.881373587019543
acosh ( input_value ) → inverse_hyperbolic_cosineReturns the inverse hyperbolic cosine (in double precision) of a given value (in double precision).acosh(2.0) → 1.3169578969248166
atanh ( input_value ) → inverse_hyperbolic_tangentReturns the inverse hyperbolic tangent (in double precision) of a given value (in double precision).atanh(0.5) → 0.5493061443340549
sind ( degrees ) → sineReturns the trigonometric sine (in double precision) of an angle measured in degrees (in double precision).sind(15) → 0.2588190451025208
cosd ( degrees ) → cosineReturns the trigonometric cosine (in double precision) of an angle measured in degrees (in double precision).cosd(15) → 0.9659258262890683
tand ( degrees ) → tangentReturns the trigonometric tangent (in double precision) of an angle measured in degrees (in double precision).tand(15) → 0.26794919243112275
cotd ( degrees ) → cotangentReturns the trigonometric cotangent (in double precision) of an angle measured in degrees (in double precision)cotd(45) → 1

Degrees and radians functions

FunctionDescriptionExample
degrees ( radians ) → degreesReturns the conversion (in double precision) of an angle measured in radians (in double precision) to degrees.degrees(pi()/2) → 90
radians ( degrees ) → radiansReturns the conversion (in double precision) of an angle measured in degrees (in double precision) to radians.radians(180) → 3.141592653589793

Help us make this doc better!