Arithmetic
Provides mathematical operations.
add
Introduced: 5.6.0
add(arg0, arg1, ...)
Creates an addition (+) operator that applies to a variable number of expression arguments. Arguments must all be either 'float_expr' or 'integer_expr'.
- arg0 (number_expr)
- arg1 (number_expr)
- ... (number_expr)
Returns: (number_value)
Example: Find records where the sum of the value in bin 'apples' and the value in bin 'bananas' is greater than 10.
- C
- Java
as_exp_build(predexp,
as_exp_cmp_gt(
as_exp_add(
as_exp_bin_int("apples"),
as_exp_bin_int("bananas")),
as_exp_int(10)));
Expression exp = Exp.build(
Exp.gt(
Exp.add(
Exp.intBin("apples"),
Exp.intBin("bananas")),
Exp.val(10)));
sub
Introduced: 5.6.0
sub(arg0, arg1, ...)
Creates a subtract operator (-) that applies to a variable number of expression arguments. Arguments must all be either 'float_expr' or 'integer_expr'. Subtracts arguments from left to right:
- sub(10,5) = (10-5) = 4
- sub(10,5,1) = (10 - (5 + 1)) = 1 or, in alternate notation, ((10 - 5) - 1).
- Negates single arguments: sub(-1) = 1 and sub(1) = -1.
- arg0 (number_expr)
- arg1 (number_expr)
- ... (number_expr)
Returns: (number_value)
Example: Find records where the difference between the value in bin 'assets' and the value in bin 'debts' is less than 1000000.
- C
- Java
as_exp_build(predexp,
as_exp_cmp_lt(
as_exp_sub(
as_exp_bin_int("assets"),
as_exp_bin_int("debts")),
as_exp_int(1000000)));
Expression exp = Exp.build(
Exp.lt(
Exp.sub(
Exp.intBin("assets"),
Exp.intBin("debts")),
Exp.val(1000000)));
mul
Introduced: 5.6.0
mul(arg0, arg1, ...)
Creates a multiplication operator (*) that applies to a variable number of expression arguments. If only one argument is supplied, returns that argument. Arguments must all be either 'float_expr' or 'integer_expr'.
- arg0 (number_expr)
- arg1 (number_expr)
- ... (number_expr)
Returns: (number_value)
Example: Find records where the product of the value in bin height
and the value in bin width
is less than 100.
- C
- Java
as_exp_build(predexp,
as_exp_cmp_lt(
as_exp_mul(
as_exp_bin_int("height"),
as_exp_bin_int("width")),
as_exp_int(100)));
Expression exp = Exp.build(
Exp.lt(
Exp.mul(
Exp.intBin("assets"),
Exp.intBin("debts")),
Exp.val(100)));
div
Introduced: 5.6.0
div(arg0, arg1, ...)
Creates a division operator (/) that applies to a variable number of expression arguments. Divides arguments from left to right, such that div(10,5) equals (10/5) and div(10,5,2) equals (10 / (5 * 2)), or, in alternate notation, ((10 / 5) / 2). If only one argument is supplied, returns the reciprocal (1/x) for that argument or, if the single argument is an integer type, returns 0 to avoid type incompatibility (as the reciprocal of an integer is a fraction). Arguments must all be either 'float_expr' or 'integer_expr'.
- arg0 (number_expr)
- arg1 (number_expr)
- ... (number_expr)
Returns: (number_value)
Example: Find records where the value in bin 'candy' divided by the value in bin 'children' is less than 1.0.
- C
- Java
as_exp_build(predexp,
as_exp_cmp_lt(
as_exp_div(
as_exp_to_float(as_exp_bin_int("candy")),
as_exp_to_float(as_exp_bin_int("kids"))),
as_exp_float(1.0)));
Expression exp = Exp.build(
Exp.lt(
Exp.div(
Exp.toFloat(Exp.intBin("candy")),
Exp.toFloat(Exp.intBin("kids"))),
Exp.val(1.0)));
pow
Introduced: 5.6.0
pow(base, exponent)
Creates a "pow" operator that raises the base "base" to the power of "exponent". Arguments must all be 'float_expr'.
- base (float_expr)
- exponent (float_expr)
Returns: (float_value)
Example: Find records where the value in bin 'p' raised to the value in bin 'events' is less than 0.5.
- C
- Java
as_exp_build(predexp,
as_exp_cmp_lt(
as_exp_pow(as_exp_bin_float("p"),
as_exp_to_float(as_exp_bin_int("events"))),
as_exp_float(0.5));
Expression exp = Exp.build(
Exp.lt(
Exp.pow(Exp.intBin("p"), Exp.toFloat(Exp.intBin("events"))),
Exp.val(0.5)));
log
Introduced: 5.6.0
log(num, base)
Creates a "log" operator for the logarithm of the number "num" with base "base". Arguments must all be 'float_expr'.
- num (float_expr)
- base (float_expr)
Returns: (float_value)
Example: Find records where log of the value in bin 'branches' base 8 is greater than 2.
- C
- Java
as_exp_build(predexp,
as_exp_cmp_gt(
as_exp_log(as_exp_bin_float("branches"), as_exp_float(8.0)),
as_exp_float(2.0)));
Expression exp = Exp.build(
Exp.lt(
Exp.log(Exp.floatBin("branches"), Exp.val(8.0))),
Exp.val(2.0)));
mod
Introduced: 5.6.0
mod(numerator, denominator)
Creates a modulo operator (%) that determines the remainder of "numerator" divided by "denominator". Arguments must all be 'integer_expr'.
- numerator (integer_expr)
- denominator (integer_expr)
Returns: (integer_value)
Example: Find records where the value in bin "value" modulo 2 equals 0.
- C
- Java
as_exp_build(predexp,
as_exp_cmp_eq(
as_exp_mod(as_exp_bin_int("value"), as_exp_int(2)),
as_exp_int(0)));
Expression exp = Exp.build(
Exp.eq(
Exp.mod(Exp.intBin("value"), Exp.val(2))),
Exp.val(0)));
abs
Introduced: 5.6.0
abs(value)
Creates an absolute-value operator that returns the absolute value of a number. The argument must be either an 'integer_expr' or a 'float_expr'.
- value (number_expr)
Returns: (number_value)
Example: Find records where the absolute value of the difference between the value in bin 'x1' and the value in bin 'x2' is greater than 1.
- C
- Java
as_exp_build(predexp,
as_exp_cmp_gt(
as_exp_abs(as_exp_sub(
as_exp_bin_int("x1"), as_exp_bin_int("x2"))),
as_exp_int(1)));
Expression exp = Exp.build(
Exp.gt(
Exp.abs(Exp.sub(
Exp.intBin("x1"), Exp.intBin("x2"))),
Exp.val(1)));
floor
Introduced: 5.6.0
floor(value)
Creates an expression that rounds a floating-point number down to the closest integer value. The argument must be a 'float_expr'.
- value (float_expr)
Returns: (float_value)
Example: Find records where the floor of the value in the bin "value" equals 2.0.
- C
- Java
as_exp_build(predexp,
as_exp_cmp_eq(
as_exp_floor(as_exp_bin_float("value")),
as_exp_float(2.0)));
Expression exp = Exp.build(
Exp.eq(
Exp.floor(Exp.floatBin("value")),
Exp.val(2.0)));
ceil
Introduced: 5.6.0
ceil(value)
Creates an expression that rounds a floating-point number up to the closest integer value. The argument must be a 'float_expr'.
- value (float_expr)
Returns: (float_value)
Example: Find records where the ceiling of the value in the bin "value" equals 2.0.
- C
- Java
as_exp_build(predexp,
as_exp_cmp_eq(
as_exp_ceil(as_exp_bin_float("value")),
as_exp_float(2.0)));
Expression exp = Exp.build(
Exp.eq(
Exp.ceil(Exp.floatBin("value")),
Exp.val(2.0)));
to_int
Introduced: 5.6.0
to_int(value)
Creates an expression that converts a floating-point value to an integer value. The argument must be a `float_expr'.
- value (float_expr)
Returns: (integer_value)
to_float
Introduced: 5.6.0
to_float(value)
Creates an expression that converts an integer value to a floating-point value. The argument must be a 'float_expr'.
- value (integer_expr)
Returns: (float_value)
int_and
Introduced: 5.6.0
int_and(arg0, arg1, ...)
Creates an "and" operator (&) that is applied to two or more integers. All arguments must resolve to integers.
- arg0 (integer_expr)
- arg1 (integer_expr)
- ... (integer_expr)
Returns: (integer_value)
Example: Find records where bin "flags" bitwise-and mask 0xF is non-zero.
- C
- Java
as_exp_build(predexp,
as_exp_cmp_ne(
as_exp_int_and(as_exp_bin_int("flags"), as_exp_int(0xF)),
as_exp_int(0)));
Expression exp = Exp.build(
Exp.ne(
Exp.intAnd(Exp.intBin("flags"), Exp.val(0xF)),
Exp.val(0)));
int_or
Introduced: 5.6.0
int_or(arg0, arg1, ...)
Creates an "or" operator (|) that is applied to two or more integers. All arguments must resolve to integers.
- arg0 (integer_expr)
- arg1 (integer_expr)
- ... (integer_expr)
Returns: (integer_value)
Example: Set flag 0x8 in bin "flags" using bitwise-or.
- C
- Java
as_exp_build(predexp,
as_exp_int_or(as_exp_bin_int("flags"), as_exp_int(0x8)));
Expression exp = Exp.build(
Exp.intOr(Exp.intBin("flags"), Exp.val(0x8)));
int_xor
Introduced: 5.6.0
int_xor(arg0, arg1, ...)
Creates an "xor" operator (^) that is applied to two or more integers. All arguments must resolve to integers.
- arg0 (integer_expr)
- arg1 (integer_expr)
- ... (integer_expr)
Returns: (integer_value)
Example: Toggle flag 0x8 in bin "flags" using bitwise-xor.
- C
- Java
as_exp_build(predexp,
as_exp_int_xor(as_exp_bin_int("flags"), as_exp_int(0x8)));
Expression exp = Exp.build(
Exp.intXor(Exp.intBin("flags"), Exp.val(0x8)));
int_not
Introduced: 5.6.0
int_not(value)
Creates a "not" operator (~) that is applied to an integer.
- value (integer_expr)
Returns: (integer_value)
Example: Toggle all bits in bin "flags" using bitwise-not.
- C
- Java
as_exp_build(predexp, as_exp_int_not(as_exp_bin_int("flags"));
Expression exp = Exp.build(Exp.intNot(Exp.intBin("flags")));
int_lshift
Introduced: 5.6.0
int_lshift(value, by_numbits)
Creates a left-shift operator (<<) for use with integers.
- value (integer_expr)
- by_numbits (integer_value)
Returns: (integer_value)
Example: Shift the value in bin "visits" left by one bit.
- C
- Java
as_exp_build(predexp, as_exp_int_lshift(
as_exp_bin_int("visits"), as_exp_int(1));
Expression exp = Exp.build(
Exp.lshift(Exp.intBin("visits"), Exp.val(1)));
int_rshift
Introduced: 5.6.0
int_rshift(value, by_numbits)
Creates a logical right-shift operator (>>>) for use with integers.
- value (integer_expr)
- by_numbits (integer_value)
Returns: (integer_value)
Example: Determine whether the 6th bit from the left is set in the value in the bin "flags".
- C
- Java
as_exp_build(predexp,
as_exp_eq(
as_exp_int_and(
as_exp_int_rshift(as_exp_bin_int("flags"), as_exp_int(6)),
as_exp_int(1)),
as_exp_int(1)));
Expression exp = Exp.build(
Exp.eq(
Exp.intAnd(
Exp.rshift(Exp.intBin("flags"), Exp.val(6)),
Exp.val(1)),
Exp.Val(1)));
int_arshift
Introduced: 5.6.0
int_arshift(value, by_numbits)
Creates an arithmetic right-shift operator (>>) for use with integers.
- value (integer_expr)
- by_numbits (integer_value)
Returns: (integer_value)
Example: Use the arithmetic right-shift operator to divide the value of the bin "value" by 8.
- C
- Java
as_exp_build(predexp,
as_exp_int_arshift(as_exp_bin_int("value"), as_exp_int(3)));
Expression exp = Exp.build(
Exp.arshift(Exp.intBin("value"), Exp.val(3)));
int_count
Introduced: 5.6.0
int_count(value)
Creates an expression that returns a count of integer bits that are set to 1.
- value (integer_expr)
Returns: (integer_value)
Example: Find records where the bit count of the value in bin "visits" is greater than 15.
- C
- Java
as_exp_build(predexp,
as_exp_cmp_gt(
as_exp_int_count(as_exp_bin_int("visits")),
as_exp_int(15)));
Expression exp = Exp.build(
Exp.gt(
Exp.count(Exp.intBin("visits")),
Exp.val(30)))
int_lscan
Introduced: 5.6.0
int_lscan(value, search)
Creates an expression that scans integer bits from the left (the most significant bit) to the right (the least significant bit), looking for a bit value. When the value is found, the index of that bit (where the most significant bit is index 0) is returned. If "search" is true, the scan searches for the bit value 1. If "search" is false, it searches for the bit value 0.
- value (integer_expr)
- search (boolean_expr)
Returns: (integer_value)
Example: Find records in which the leading 30 bits of the value in the bin "value" are not set.
- C
- Java
as_exp_build(predexp,
as_exp_cmp_gt(
as_exp_int_lscan(
as_exp_bin_int("value"), as_exp_bool(false)),
as_exp_int(30)));
Expression exp = Exp.build(
Exp.gt(
Exp.lscan(Exp.intBin("value"), Exp.val(false)),
Exp.val(30)));
int_rscan
Introduced: 5.6.0
int_rscan(value, search)
Create expression that scans integer bits from right (the least significant bit) to left (the most significant bit), looking for a search bit value. When the search value is found, the index of that bit (where the most significant bit is index 0) is returned. If "search" is true, the scan will search fro the bit value 1. If "search is false it will search for bit value 0.
- value (integer_expr)
- search (boolean_expr)
Returns: (integer_value)
Example: Find records where the bin "visits" encodes that there has been a visit within the last 7 cycles.
- C
- Java
as_exp_build(predexp,
as_exp_cmp_gt(
as_exp_int_rscan(
as_exp_bin_int("visits"), as_exp_bool(true)),
as_exp_int(64 - 7)));
Expression exp = Exp.build(
Exp.gt(
Exp.rscan(Exp.intBin("visits"), Exp.val(true)),
Exp.val(64 - 7)));
min
Introduced: 5.6.0
min(arg0, arg1, ...)
Creates an expression that returns the minimum value in a variable number of expressions. Arguments must all be either 'float_expr' or 'integer_expr'.
- arg0 (number_expr)
- arg1 (number_expr)
- ... (number_expr)
Returns: (number_value)
Example: Find records where the minimum bin value is less than 10.
- C
- Java
as_exp_build(predexp,
as_exp_cmp_lt(
as_exp_min(
as_exp_bin_int("value0"),
as_exp_bin_int("value1"),
as_exp_bin_int("value2"),
as_exp_bin_int("value3")),
as_exp_int(10)));
Expression exp = Exp.build(
Exp.lt(
Exp.min(
Exp.intBin("value0"),
Exp.intBin("value1"),
Exp.intBin("value2"),
Exp.intBin("value3")),
Exp.val(10)));
max
Introduced: 5.6.0
max(arg0, arg1, ...)
Creates an expression that returns the maximum value in a variable number of expressions. Arguments must all be either 'float_expr' or 'integer_expr'.
- arg0 (number_expr)
- arg1 (number_expr)
- ... (number_expr)
Returns: (number_value)
Example: Find records where the maximum bin value is greater than 100.
- C
- Java
as_exp_build(predexp,
as_exp_cmp_gt(
as_exp_max(
as_exp_bin_int("value0"),
as_exp_bin_int("value1"),
as_exp_bin_int("value2"),
as_exp_bin_int("value3")),
as_exp_int(190)));
Expression exp = Exp.build(
Exp.gt(
Exp.max(
Exp.intBin("value0"),
Exp.intBin("value1"),
Exp.intBin("value2"),
Exp.intBin("value3")),
Exp.val(190)));