This topic describes the syntax and parameters of arithmetic functions. This topic also provides examples on how to use the functions.

Functions

Note If you want to pass a negative integer, use op_neg(Positive integer). For example, use op_neg(1) to indicate -1.
Category Function Description
Sum calculation op_sum Returns the sum of input values.
Basic calculation op_abs Returns the absolute value of an input value.
op_div_floor Returns the integer part of the quotient of two input values.
op_div_true Returns the quotient of two input values.
op_pow Returns a value raised to a specified power.
op_mul Returns the product of two input values.
op_neg Returns the opposite number of an input value.
op_mod Returns the remainder of an input value divided by the other input value.
op_sub Returns the difference between two input values.
op_round Rounds an input value.
Mathematical calculation mat_ceil Rounds an input value up to the nearest integer.
mat_exp Returns Euler's number raised to the power of an input value.
mat_fabs Returns the absolute value of an input value.
mat_floor Rounds an input value down to the nearest integer.
mat_log Returns the logarithm of an input value with the base specified by the other input value.
mat_log10 Returns the base-10 logarithm of an input value.
mat_sqrt Returns the square root of an input value.
mat_degrees Converts radians to degrees.
mat_radians Converts degrees to radians.
mat_sin Returns the sine of an input value in radians.
mat_cos Returns the cosine of an input value in radians.
mat_tan Returns the tangent of an input value in radians.
mat_acos Returns the arc cosine of an input value in radians.
mat_asin Returns the arc sine of an input value in radians.
mat_atan Returns the arc tangent of an input value in radians.
mat_atan2 Returns the arc tangent of X and Y coordinates.
mat_atanh Returns the inverse hyperbolic tangent of an input value.
mat_hypot Returns the Euclidean norm of two input values.
MATH_PI Obtains the constant pi.
MATCH_E Obtains the constant e.

op_sum

The function is used to return the sum of input values.
  • Syntax

    op_sum(value1, value2, ...)
  • Parameters

    Parameter Type Required Description
    value1 Number or numeric string Yes The value that you want to use for the calculation.
    value2 Number or numeric string Yes The value that you want to use for the calculation.
  • Response

    The sum of all input values is returned.

  • Examples

    Calculate the sum of the values of the course_price and goods_price fields.

    • Raw log:
      course_price: 12
      goods_price: 2
    • Transformation rule:
      e_set("account", op_sum(v("course_price"), v("goods_price")))
    • Result:
      course_price: 12
      goods_price: 2
      account: 14

op_abs

The function is used to return the absolute value of an input value.
  • Syntax

    op_abs(value)
  • Parameters

    Parameter Type Required Description
    value Number or numeric string Yes The value that you want to use for the calculation.
  • Response

    The absolute value of the input value is returned.

  • Examples

    Calculate the absolute value of the value of the course_price field.

    • Raw log:
      course_price: -4
    • Transformation rule:
      e_set("op_abs", op_abs(v("course_price")))
    • Result:
      course_price: -4
      op_abs: 4

op_div_floor

The function is used to return the integer part of the quotient of two input values.
  • Syntax

    op_div_floor(value1, value2)
  • Parameters

    Parameter Type Required Description
    value1 Number or numeric string Yes The value that you want to use for the calculation.
    value2 Number or numeric string Yes The value that you want to use for the calculation.
  • Response

    The integer part of the quotient that is obtained after Value 1 is divided by Value 2 is returned.

  • Examples

    Calculate the unit price based on the values of the course_price and count fields.

    • Raw log:
      course_price: 4
      count: 2
    • Transformation rule:
      e_set("op_div_floor", op_div_floor(v("course_price"), v("count")))
    • Result:
      course_price: 4
      count: 2
      op_div_floor: 2

op_div_true

The function is used to calculate the quotient of two input values.
Note The op_div_true function automatically converts the data types of input values. The input value can be a string or an integer.
  • Syntax

    op_div_true(value1, value2)
  • Parameters

    Parameter Type Required Description
    value1 Number or numeric string Yes The value that you want to use for the calculation.
    value2 Number or numeric string Yes The value that you want to use for the calculation.
  • Response

    The quotient that is obtained after Value 1 is divided by Value 2 is returned.

  • Examples

    • Example 1: Calculate the unit price based on the values of the fruit_price and count fields.
      • Raw log:
        fruit_price: 9
        count: 2
      • Transformation rule:
        e_set("op_div_true", op_div_true(v("fruit_price"), v("count")))
      • Result:
        fruit_price: 9
        count: 2
        op_div_true: 4.5
    • Example 2: Calculate the acceleration based on the values of the one_speed and two_speed fields. The return value is rounded. Formula: a = (one_speed - two_speed)/time.
      • Raw log:
        one_speed: 9
        two_speed: 2
        time: 3
      • Transformation rule:
        e_set("a", op_round(op_div_true(op_sub(v("one_speed"), v("two_speed")), v("time")), 2))
      • Result:
        a:2.33
        one_speed:9
        time:3
        two_speed:2

op_pow

The function is used to return a value raised to a specified power.
  • Syntax

    op_pow(value1, value2)
  • Parameters

    Parameter Type Required Description
    value1 Number or numeric string Yes The value that you want to use for the calculation.
    value2 Number or numeric string Yes The value that you want to use for the calculation.
  • Response

    Value 1 raised to the power of Value 2 is returned.

  • Examples

    Calculate the value of the course field raised to the power of the value of the pow field.

    • Raw log:
      course: 100
      pow: 2
    • Transformation rule:
      e_set("pow_course", op_pow(v("course"), v("pow")))
    • Result:
      course: 100
      pow: 2
      pow_course: 10000

op_mul

The function is used to return the product of two input values.
  • Syntax

    op_mul(value1, value2)
  • Parameters

    Parameter Type Required Description
    value1 Number, string, tuple, or list Yes The value that you want to use for the calculation.
    value2 Number Yes The value that you want to use for the calculation.
  • Response

    • If Value 1 and Value 2 are numbers, the product of Value 1 and Value 2 is returned.
    • If Value 1 and Value 2 are strings, tuples, or lists, the specified number of duplicates of the original value is returned.
  • Examples

    • Example 1: Calculate the product of the values of the course and price fields.
      • Raw log:
        course: 10
        price: 23
      • Transformation rule:
        e_set("account", op_mul(ct_int(v("course")), ct_int(v("price"))))
      • Result:
        course: 10
        price: 23
        account: 230
    • Example 2: Return three duplicates of the original value of the course field.
      • Raw log:
        course: "abc"
      • Transformation rule:
        e_set("course", op_mul(v("course"), 3))
      • Result:
        course: "abcabcabc"

op_neg

The function is used to return the opposite number of an input value.
  • Syntax

    op_neg(value)
  • Parameters

    Parameter Type Required Description
    value Number or numeric string Yes The value that you want to use for the calculation.
  • Response

    The opposite number of the input value is returned.

  • Examples

    • Raw log:
      course: -100
    • Transformation rule:
      e_set("account", op_neg(v("course_price")))
    • Result:
      course: -100
      account: 100

op_mod

The function is used to return the remainder of an input value divided by the other input value.
  • Syntax

    op_mod(value1, value2)
  • Parameters

    Parameter Type Required Description
    value1 Number or numeric string Yes The value that you want to use for the calculation.
    value2 Number or numeric string Yes The value that you want to use for the calculation.
  • Response

    The remainder that is obtained after Value 1 is divided by Value 2 is returned.

  • Examples

    • Raw log:
      course: 4
      count: 3
    • Transformation rule:
      e_set("op_mod", op_mod(v("course"), v("count")))
    • Result:
      course: 4
      count: 3
      op_mod: 1

op_sub

The function is used to return the difference between two input values.
  • Syntax

    op_sub(value1, value2)
  • Parameters

    Parameter Type Required Description
    value1 Number or numeric string Yes The value that you want to use for the calculation.
    value2 Number or numeric string Yes The value that you want to use for the calculation.
  • Response

    The difference between Value 1 and Value 2 is returned.

  • Examples

    Calculate the difference between the values of the count and count_apple fields.

    • Raw log:
      count: 6
      count_apple: 3
    • Transformation rule:
      e_set("sub_number", op_sub(v("count"),v("count_apple")))
    • Result:
      count: 6
      count_apple: 3
      sub_number:  3

op_round

The function is used to round an input value.
  • Syntax

    op_round(value, number)
  • Parameters

    Parameter Type Required Description
    value Number or numeric string Yes The value that you want to use for the calculation.
    number Number Yes The number of decimal places to which the value is rounded. Default value: 0.
  • Response

    The rounded input value is returned.

  • Examples

    Round the value of the price field to one decimal place.

    • Raw log:
      price: 4.56
    • Transformation rule:
      e_set("round_price", op_round(v("price"),1))
    • Result:
      price: 4.56
      round_price: 4.6

mat_ceil

The function is used to round an input value up to the nearest integer.
  • Syntax

    mat_ceil(value)
  • Parameters

    Parameter Type Required Description
    value Number or numeric string Yes The value that you want to use for the calculation.
  • Response

    The smallest integer that is not less than the input value is returned.

  • Examples

    • Raw log:
      price: 4.1
    • Transformation rule:
      e_set("mat_ceil", mat_ceil(v("price")))
    • Result:
      price: 4.1
      mat_ceil: 5

mat_exp

The function is used to calculate Euler's number raised to the power of an input value.
  • Syntax

    mat_exp(value)
  • Parameters

    Parameter Type Required Description
    value Number or numeric string Yes The value that you want to use for the calculation.
  • Response

    Euler's number raised to the power of the input value is returned.

  • Examples

    • Raw log:
      number: 2
    • Transformation rule:
      e_set("e_x", mat_exp(v("number")))
    • Result:
      number: 1
      e_x: 7.38905609893065

mat_fabs

The function is used to return the absolute value of an input value.
  • Syntax

    mat_fabs(value)
  • Parameters

    Parameter Type Required Description
    value Number or numeric string Yes The value that you want to use for the calculation.
  • Response

    The absolute value of the input value is returned.

  • Examples

    • Raw log:
      course_price: -10
    • Transformation rule:
      e_set("mat_fabs", mat_fabs(v("course_price")))
    • Result:
      course_price: -10
      mat_fabs: 10.0

mat_floor

The function is used to round an input value down to the nearest integer.
  • Syntax

    mat_floor(value)
  • Parameters

    Parameter Type Required Description
    value Number or numeric string Yes The value that you want to use for the calculation.
  • Response

    The largest integer that is not greater than the input value is returned.

  • Examples

    • Raw log:
      course_price: 4.9
    • Transformation rule:
      e_set("mat_floor", mat_floor(v("course_price")))
    • Result:
      course_price: 4.9
      mat_floor: 4

mat_log

The function is used to return the logarithm of an input value with the base specified by the other input value.
  • Syntax

    mat_log(value1,value2)
  • Parameters

    Parameter Type Required Description
    value1 Number or numeric string Yes The value that you want to use for the calculation.
    value2 Number or numeric string Yes The value that you want to use for the calculation.
  • Response

    The logarithm of Value 1 with base Value 2 is returned.

  • Examples

    • Raw log:
      number1: 100
      number2: 10
    • Transformation rule:
      e_set("mat_log", mat_log(v("number1"),v("number2")))
    • Result:
      number1: 100
      number2: 10
      mat_log: 2.0

mat_log10

The function is used to return the base-10 logarithm of an input value.
  • Syntax

    mat_log10(value)
  • Parameters

    Parameter Type Required Description
    value Number or numeric string Yes The value that you want to use for the calculation.
  • Response

    The base-10 logarithm of the input value is returned.

  • Examples

    • Raw log:
      number: 100
    • Transformation rule:
      e_set("number2", mat_log10(v("number")))
    • Result:
      number: 100
      numbe2: 2.0

mat_sqrt

The function is used to return the square root of an input value.
  • Syntax

    mat_sqrt(value)
  • Parameters

    Parameter Type Required Description
    value Number or numeric string Yes The value that you want to use for the calculation.
  • Response

    The square root of the input value is returned.

  • Examples

    • Raw log:
      number1: 100
    • Transformation rule:
      e_set("sqrt_account", mat_sqrt(v("number1")))
    • Result:
      number1: 100
      sqrt_account: 10.0

mat_degrees

The function is used to convert radians to degrees.
  • Syntax

    mat_degrees(value)
  • Parameters

    Parameter Type Required Description
    value Number or numeric string Yes The value that you want to use for the calculation.
  • Response

    The value in degrees is returned.

  • Examples

    • Raw log:
      num: 1
    • Transformation rule:
      e_set("mat_degrees", mat_degrees(v("num")))
    • Result:
      num: 1
      mat_degrees: 57.29577951308232

mat_radians

The function is used to convert degrees to radians.
  • Syntax

    mat_radians(value)
  • Parameters

    Parameter Type Required Description
    value Number or numeric string Yes The value that you want to use for the calculation.
  • Response

    The value in radians is returned.

  • Examples

    • Raw log:
      rad: 30
    • Transformation rule:
      e_set("mat_radians", mat_radians(v("rad")))
    • Result:
      rad: 30
      mat_radians: 0.5235987755982988

mat_sin

The function is used to return the sine of an input value in radians.
  • Syntax

    mat_sin(value)
  • Parameters

    Parameter Type Required Description
    value Number or numeric string Yes The value that you want to use for the calculation.
  • Response

    The sine of the input value is returned.

  • Examples

    • Raw log:
      sin: 90
    • Transformation rule:
      e_set("mat_sin", mat_sin(v("sin")))
    • Result:
      sin: 90
      mat_sin: 0.8939966636005579

mat_cos

The function is used to return the cosine of an input value in radians.
  • Syntax

    mat_cos(value)
  • Parameters

    Parameter Type Required Description
    value Number or numeric string Yes The value that you want to use for the calculation.
  • Response

    The cosine of the input value is returned.

  • Examples

    • Raw log:
      cos: 30
    • Transformation rule:
      e_set("mat_cos", mat_cos(v("cos")))
    • Result:
      cos: 30
      mat_cos: 0.15425144988758405

mat_tan

The function is used to return the tangent of an input value in radians.
  • Syntax

    mat_tan(value)
  • Parameters

    Parameter Type Required Description
    value Number or numeric string Yes The value that you want to use for the calculation.
  • Response

    The tangent of the input value is returned.

  • Examples

    • Raw log:
      tan: 30
    • Transformation rule:
      e_set("mat_tan", mat_tan(v("tan")))
    • Result:
      tan: 30
      mat_tan: 1.6197751905438615

mat_acos

The function is used to return the arc cosine of an input value in radians.
  • Syntax

    mat_acos(value)
  • Parameters

    Parameter Type Required Description
    value Number or numeric string Yes The value that you want to use for the calculation.
  • Response

    The arc cosine of the input value is returned.

  • Examples

    • Raw log:
      acos: 1
    • Transformation rule:
      e_set("mat_acos", mat_acos(v("acos")))
    • Result:
      acos: 1
      mat_acos: 0.0

mat_asin

The function is used to return the arc sine of an input value in radians.
  • Syntax

    mat_asin(value)
  • Parameters

    Parameter Type Required Description
    value Number or numeric string Yes The value that you want to use for the calculation.
  • Response

    The arc sine of the input value is returned.

  • Examples

    • Raw log:
      asin: 1
    • Transformation rule:
      e_set("mat_asin", mat_asin(v("asin")))
    • Result:
      asin: 1
      mat_asin: 1.5707963267948966

mat_atan

The function is used to return the arc tangent of an input value in radians.
  • Syntax

    mat_atan(value)
  • Parameters

    Parameter Type Required Description
    value Number or numeric string Yes The value that you want to use for the calculation.
  • Response

    The arc tangent of the input value is returned.

  • Examples

    • Raw log:
      atan: 1
    • Transformation rule:
      e_set("mat_atan", mat_atan(v("atan")))
    • Result:
      atan: 1
      mat_atan: 0.7853981633974483

mat_atan2

The function is used to return the arc tangent of X and Y coordinates.
  • Syntax

    mat_atan2(x,y)
  • Parameters

    Parameter Type Required Description
    x Number or numeric string Yes The X-coordinate.
    y Number or numeric string Yes The Y-coordinate.
  • Response

    The arc tangent of the X-coordinate and the Y-coordinate is returned.

  • Examples

    • Raw log:
      atan1: 1
      atan2: 2
    • Transformation rule:
      e_set("mat_atan2", mat_atan2(v("atan1"),v("atan2")))
    • Result:
      atan1: 1
      atan2: 2
      mat_atan2: 0.4636476090008061

mat_atanh

The function is used to return the inverse hyperbolic tangent of an input value.
  • Syntax

    mat_atanh(value)
  • Parameters

    Parameter Type Required Description
    value Number or numeric string Yes The X-coordinate.
  • Response

    The inverse hyperbolic tangent of the input value is returned.

  • Examples

    • Raw log:
      atanh: 0.5
    • Transformation rule:
      e_set("mat_atanh", mat_atanh(v("atanh")))
    • Result:
      atanh:0.5
      mat_atanh:0.5493061443340548

mat_hypot

The function is used to return the Euclidean norm of two input values.
  • Syntax

    mat_hypot(value1,value2)
  • Parameters

    Parameter Type Required Description
    value1 Number or numeric string Yes The X-coordinate.
    value2 Number or numeric string Yes The Y-coordinate.
  • Response

    The Euclidean norm of the input values is returned.

  • Examples

    • Raw log:
      hypot1: 1
      hypot2: 2
    • Transformation rule:
      e_set("mat_hypot", mat_hypot(v("hypot1"),v("hypot2")))
    • Result:
      hypot1:1
      hypot2:2
      mat_hypot:2.23606797749979

MATH_PI

The function is used to obtain the constant pi.
  • Raw log:
    a:2
  • Transformation rule:
    e_set("result", op_sum(v("a"), MATH_PI))
  • Result:
    a:2
    result:5.141592653589793

MATCH_E

The function is used to obtain the constant e.
  • Raw log:
    a:2
  • Transformation rule:
    e_set("result", op_sum(v("a"), MATCH_E))
  • Result:
    a:2
    result:4.718281828459045