Skip to main content
Loading

Arithmetic

Provides mathematical operations.

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'.

Arguments:
  • 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.

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)));

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.
Arguments:
  • 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.

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)));

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'.

Arguments:
  • 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.

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)));

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'.

Arguments:
  • 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.

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)));

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'.

Arguments:
  • 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.

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));

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'.

Arguments:
  • 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.

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)));

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'.

Arguments:
  • numerator (integer_expr)
  • denominator (integer_expr)

Returns: (integer_value)

Example: Find records where the value in bin "value" modulo 2 equals 0.

as_exp_build(predexp,
as_exp_cmp_eq(
as_exp_mod(as_exp_bin_int("value"), as_exp_int(2)),
as_exp_int(0)));

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'.

Arguments:
  • 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.

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)));

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'.

Arguments:
  • value (float_expr)

Returns: (float_value)

Example: Find records where the floor of the value in the bin "value" equals 2.0.

as_exp_build(predexp,
as_exp_cmp_eq(
as_exp_floor(as_exp_bin_float("value")),
as_exp_float(2.0)));

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'.

Arguments:
  • value (float_expr)

Returns: (float_value)

Example: Find records where the ceiling of the value in the bin "value" equals 2.0.

as_exp_build(predexp,
as_exp_cmp_eq(
as_exp_ceil(as_exp_bin_float("value")),
as_exp_float(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'.

Arguments:
  • 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'.

Arguments:
  • 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.

Arguments:
  • arg0 (integer_expr)
  • arg1 (integer_expr)
  • ... (integer_expr)

Returns: (integer_value)

Example: Find records where bin "flags" bitwise-and mask 0xF is non-zero.

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)));

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.

Arguments:
  • arg0 (integer_expr)
  • arg1 (integer_expr)
  • ... (integer_expr)

Returns: (integer_value)

Example: Set flag 0x8 in bin "flags" using bitwise-or.

as_exp_build(predexp,
as_exp_int_or(as_exp_bin_int("flags"), as_exp_int(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.

Arguments:
  • arg0 (integer_expr)
  • arg1 (integer_expr)
  • ... (integer_expr)

Returns: (integer_value)

Example: Toggle flag 0x8 in bin "flags" using bitwise-xor.

as_exp_build(predexp,
as_exp_int_xor(as_exp_bin_int("flags"), as_exp_int(0x8)));

int_not

Introduced: 5.6.0

int_not(value)

Creates a "not" operator (~) that is applied to an integer.

Arguments:
  • value (integer_expr)

Returns: (integer_value)

Example: Toggle all bits in bin "flags" using bitwise-not.

as_exp_build(predexp, as_exp_int_not(as_exp_bin_int("flags"));

int_lshift

Introduced: 5.6.0

int_lshift(value, by_numbits)

Creates a left-shift operator (<<) for use with integers.

Arguments:
  • value (integer_expr)
  • by_numbits (integer_value)

Returns: (integer_value)

Example: Shift the value in bin "visits" left by one bit.

as_exp_build(predexp, as_exp_int_lshift(
as_exp_bin_int("visits"), as_exp_int(1));

int_rshift

Introduced: 5.6.0

int_rshift(value, by_numbits)

Creates a logical right-shift operator (>>>) for use with integers.

Arguments:
  • 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".

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)));

int_arshift

Introduced: 5.6.0

int_arshift(value, by_numbits)

Creates an arithmetic right-shift operator (>>) for use with integers.

Arguments:
  • 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.

as_exp_build(predexp,
as_exp_int_arshift(as_exp_bin_int("value"), as_exp_int(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.

Arguments:
  • value (integer_expr)

Returns: (integer_value)

Example: Find records where the bit count of the value in bin "visits" is greater than 15.

as_exp_build(predexp,
as_exp_cmp_gt(
as_exp_int_count(as_exp_bin_int("visits")),
as_exp_int(15)));

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.

Arguments:
  • 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.

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)));

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.

Arguments:
  • 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.

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)));

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'.

Arguments:
  • arg0 (number_expr)
  • arg1 (number_expr)
  • ... (number_expr)

Returns: (number_value)

Example: Find records where the minimum bin value is less than 10.

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)));

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'.

Arguments:
  • arg0 (number_expr)
  • arg1 (number_expr)
  • ... (number_expr)

Returns: (number_value)

Example: Find records where the maximum bin value is greater than 100.

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)));