abs
Evaluates to the absolute value of the parameter. Evaluates to null if the parameter is null.
Used in the following format, where num
must be numeric:
abs(num)
num.abs()
The return value type is the same as num
.
Examples
abs(-15) # value: 15
-15.abs() # value: 15
(abs 1.7) # value: 1.7
1.7.abs() # value: 1.7
acos
Returns the arc cosine of value
.
Used in the following format, where value
must be numeric:
acos(value)
value.acos()
The return value type is double.
Examples
acos(0) # value: 1.57079
0.acos() # value: 1.57079
add
Evaluates the sum of the parameters. Ignores any null parameters. If all parameters are null, evaluates to null. When adding a long to a datetime, the long is assumed to represent milliseconds.
Used in the following format, where num
must be numeric, datetime
must be a datetime and interval
must be a long integer:
add({num}+)
add(datetime, interval)
The return value type is a coordinated numeric type of the parameters.
Examples
add(5, 7) # value: 12
add(7, long(5), -10) # value: -2 (long)
add(timestamp(), 24*60*60*long(1000)) # value: tomorrow
asin
Returns the arc sine of value
.
Used in the following format, where value
must be numeric:
asin(value)
The return value type is a double.
Examples
asin(0) # value: 0.0
0.asin() # value: 0.0
atan
Returns the arc tangent of value
.
Used in the following format, where value
must be numeric:
atan(value)
value.atan()
The return value type is a double.
Examples
atan(1) # value: 0.78539
1.atan() # value: 0.78539
avg
Calculates the average (arithmetic mean) of the parameters. Ignores any null parameters. If all parameters are null, evaluates to null.
Used in the following format, where nums
must be numeric:
avg({nums}+)
The return value type is a double.
Examples
avg(-1, 3.2, null, long(17)) # value: 6.4
ceil
Finds the ceiling of a number. Evaluates to the smallest integer greater than or equal to the parameter. Evaluates to null if the parameter is null.
Used in the following format, where num
must be numeric:
ceil(num)
num.ceil()
The return value type is a double.
Examples
ceil(3.25) # value: 4.0
3.25.ceil() # value: 4.0
ceil(5) # value: 5.0
5.ceil() # value: 5.0
ceil(-15.3) # value: -15.0
-15.3.ceil() # value: -15.0
cos
Returns the cosine of value
.
Used in the following format, where value
must be numeric:
cos(value)
value.cos()
The return value type is a double.
Examples
cos(0) # value: 1.0
0.cos() # value: 1.0
div
Evaluates the dividend of the parameters. If at least one of the parameters is a non-integer, regular division is performed. If both parameters are integers, integer division is performed. To perform regular division with integer parameters, use the "/" operator.
Used in the following format, where numerator
must be numeric and denominator
must be numeric:
div(numerator, denominator)
The return value type is a coordinated numeric type of the parameters.
Examples
div(10, 2) # value: 5
div(3, 5) # value: 0
div(10.0, 2) # value: 5.0
div(3.0, 5) # value: 0.6
double
Converts the parameter to a double. Errors if not convertible. The parameter must be convertible to a double. Use the isNumber operator to query whether a value is convertible. All boolean, integer, long integer, and double values are convertible. String values are convertible if formatted correctly. No other types are convertible. If the parameter is null, evaluates to null.
Used in the following format, where
input
may be any value convertible to double:
double(input)
The return value type is a double.
Examples
double(long(3)) # value: 3.0
double(long(3)) # value: 3.0
double(true) # value: 1.0
true.double() # value: 1.0
double("-3.14159") # value: -3.14159
"-3.14159".double() # value: -3.14159
double("5 + 2") # ERROR
"5 + 2".double() # ERROR
double(date(0)) # ERROR
date(0).double() # ERROR
floor
Evaluates to the largest integer less than or equal to the parameter. Evaluates to null if the parameter is null.
Used in the following format, where num
must be numeric:
floor(num)
num.floor()
The return value type is a double.
Examples
floor(3.25) # value: 3.0
3.25.floor() # value: 3.0
floor(5) # value: 5.0
5.floor() # value: 5.0
floor(-15.3) # value: -16.0
-15.3.floor() # value: -16.0
int
Converts the parameter to an integer. Errors if not convertible. All boolean, integer, long integer, double, date, and time values are convertible. String values are convertible if formatted correctly. No other types are convertible. If the parameter is null, evaluates to null.
Used in the following format, where input may be any value convertible to integer:
int(input)
input.int()
The return value type is an integer.
Examples
int(long(3)) # value: 3
long(3).int() # value: 3
int(true) # value: 1
true.int() # value: 1
int(2.71828) # value: 3
2.71828.int() # value: 3
int("-24") # value: -24
"-24".int() # value: -24
int("2.71828") # ERROR
"2.71828".int() # ERROR
int(" 5 ") # value: 5
" 5 ".int() # value: 5
int(" 5 7") # ERROR
" 5 7".int() # ERROR
int(date(2006, 3, 11)) # value: 20060311
date(2006, 3, 11).int() # value: 20060311
int(time(8, 52, 4)) # value: 85204
time(8, 52, 4).int() # value: 85204
isFinite
Returns a non-zero value if value is neither infinite nor a "not-a-number" (NaN) value, and 0 otherwise.
Used in the following format, where num
must be float:
isFinite(num)
num.isFinite()
The return value type is an integer.
isInf
Returns -1 if value represents negative infinity, 1 if value represents positive infinity, and 0 otherwise.
Used in the following format, where num
must be float:
isInf(num)
num.isInf()
The return value type is an integer.
isNan
Returns a non-zero value if value is "not-a-number" (NaN), and 0 otherwise.
Used in the following format, where num
must be float:
isNan(num)
num.isNan()
The return value type is an integer.
isNumber
Evaluates to true in the following scenarios:
- If the parameter is, or can be cast to, a number.
- If the parameter is a boolean, integer, long-integer, or double.
- If the parameter is a string that can be cast to a double.
Otherwise, evaluates to false, unless the parameter is null, in which case, evaluates to null.
Used in the following format, where param
must be any expression:
isNumber(param)
param.isNumber()
The return value type is a Boolean.
Examples
isNumber(long(3)) # value: true
long(3).isNumber() # value: true
isNumber(false) # value: true
false.isNumber() # value: true
isNumber("-3.14159") # value: true
"-3.14159".isNumber() # value: true
isNumber("5 + 2") # value: false
"5 + 2".isNumber() # value: false
isNumber(date(0)) # value: false
date(0).isNumber() # value: false
"INF".isNumber() #value: true
log
Computes the logarithm of the number. The base defaults to 10. Evaluates to null if either parameter is null.
Used in the following format, where num
must be numeric and base
must be numeric (defaults to 10):
log(num, [base])
num.log([base])
The return value type is a double.
Examples
log(100) # value: 2.0
100.log() # value: 2.0
log(64, 2) # value: 6.0
64.log(2) # value: 6.0
log(.1) # value: -1.0
.1.log() # value: -1.0
log(1.414213562 2) # value: 0.5
1.414213562.log(2) # value: 0.5
long
Converts the parameter to a long integer. Errors if not convertible. All boolean, integer, long integer, double, date, datetime, and time values are convertible. String values are convertible if formatted correctly. No other types are convertible. For datetimes, the long value represents the milliseconds since 1970-1-1 00:00:00 in the local time. If the parameter is null, evaluates to null.
Used in the following format, where input
may be any value convertible to long:
long(input)
input.long()
The return value type is long integer.
Examples
long(long(3)) # value: 3 (long)
long(3).long() # value: 3 (long)
long(true) # value: 1 (long)
true.long() # value: 1 (long)
long(2.71828) # value: 3 (long)
2.71828.long() # value: 3 (long)
long("-24") # value: -24 (long)
"-24".long() # value: -24 (long)
long("2.71828") # ERROR
"2.71828".long()# ERROR
long(" 5 ") # value: 5 (long)
" 5 ".long() # value: 5 (long)
long(" 5 7") # ERROR
" 5 7".long() # ERROR
long(date(2004, 3, 11)) # value: 20040311 (long)
date(2004, 3, 11).long() # value: 20040311 (long)
long(time(8, 52, 4)) # value: 85204 (long)
time(8, 52, 4).long() # value: 85204 (long)
# value (for both): current time in milliseconds
# since 1970-1-1 local time
long(timestamp())
timestamp().long()
mod
Calculates the remainder when the given base is divided by the given modulus. If the base is null, evaluates to null. If the modulus is null, evaluates to the base.
Used in the following format, where base
must be numeric and modulus
must be numeric (defaults to the base if null):
mod(base, modulus)
base.mod(modulus)
The return value type is a coordinated numeric type of the parameters.
Examples
mod(103, 10) # value: 3
103.mod(10) # value: 3
mod(77, 2.0) # value: 1.0
77.mod(2.0) # value: 1.0
multiply
Evaluates the product of the parameters. Ignores any null parameters. If all parameters are null, evaluates to null.
Used in the following format, where num
must be numeric:
multiply({num}+)
The return value type is a coordinated numeric type of the parameters.
Examples
multiply(5, 7) # value: 35
multiply(7, long(5), -10) # value: -350 (long)
pow
Computes the base raised to the power of the specified exponent. Evaluates to null if either parameter is null.
Used in the following format, where base
and exponent
must be numeric:
pow(base, exponent)
base.pow(exponent)
The return value type is a double.
Examples
pow(10, 2) # value: 100.0
10.pow(2) # value: 100.0
pow(-3, 3) # value: -27.0
-3.pow(3) # value: -27.0
pow(2, -4) # value: 0.0625
2.pow(-4) # value: 0.0625
round
Rounds the given input number. The precision is the power of 10 at which to round; it defaults to 0 (integer rounding). The direction parameter specifies to round up, down, or to the nearest value when it is greater than, less than, or equal to zero, respectively; it defaults to 0 (nearest). If any parameters are null, evaluates to null.
Used in the following format, where input
and dir
must be numeric and precision
must be an integer or long integer:
round(input, [precision, [dir]])
The return value type is the same as input
.
Examples
round(17.3) # value: 17
17.3.round() # value: 17
round(1593, 2) # value: 1600
1593.round(2) # value: 1600
round(52.357, -2, -1) # value: 52.35
52.357.round(-2, -1) # value: 52.35
sin
Rounds the sine of value
. If any parameters are null, evaluates to null.
Used in the following format, where value
must be numeric:
sin(value)
value.sin()
The return value type is a double.
Examples
sin(0) # value: 0.0
0.sin() # value: 0.0
sqrt
Calculates the (positive) square root of the given number. If the parameter is null, evaluates to null.
Used in the following format, where num
must be numeric:
sqrt(num)
num.sqrt()
The return value type is a double.
Examples
sqrt(25) # value: 5.0
25.sqrt() # value: 5.0
sqrt(.04) # value: 0.2
.04.sqrt() # value: 0.2
sqrt(-1) # ERROR
-1.sqrt() # ERROR
square
Calculates the square of the given number. If the parameter is null, evaluates to null.
Used in the following format, where num
must be numeric:
square(num)
num.square()
The return value type is a double.
Examples
square(5) # value: 25.0
5.square() # value: 25.0
square(-.2) # value: 0.04
-.2.square() # value: 0.04
subtract
Evaluates the difference of the parameters. Ignores any null parameters. If all parameters are null, evaluates to null. Difference between datetimes will be the difference in milliseconds.
Used in the following format, where num
must be numeric and datetime1
and datetime2
must be datetimes:
subtract({num}+)
subtract(datetime1, datetime2)
The return value type is a coordinated numeric type of the parameters.
Examples
subtract(5, 7) # value: -2
subtract(7, long(5), -10) # value: 12 (long)
dt1 = timestamp(date(2001, 3, 4))
dt2 = timestamp(date(2001, 3, 5))
subtract(dt2, dt1) # value: 86400000 (long)
tan
Rounds the tangent of value
.
Used in the following format, where value
must be numeric:
tan(value)
value.tan()
The return value type is a double.
Examples
tan(0) # value: 0.0
0.tan() # value: 0.0
tan(1) # value: 1.55740
1.tan() # value: 1.55740