Updated on 2025-09-07 GMT+08:00

Arithmetic Functions

This section describes arithmetic functions, including their syntax, parameters, and usage examples.

Function List

If the value is negative, use the op_neg(positive value) function. For example, to indicate -1, use op_neg(1).

Table 1 Arithmetic functions

Type

Function

Description

Multi-value calculation and comparison

op_sum

Sums up the input values.

Basic calculation

op_abs

Performs the absolute value operation on the input value.

op_div_floor

Divides the input values exactly.

op_div_true

Divides the input values.

op_pow

Performs exponentiation on a value.

op_mul

Multiplies the input values.

op_neg

Calculates the opposite number of the input value.

op_mod

Performs the modulo operation on the input value.

op_sub

Subtracts the input values.

op_round

Rounds off the input value.

Mathematical calculation

mat_ceil

Rounds up the input value.

mat_exp

Returns the exponential value with the constant e as the base.

mat_fabs

Calculates the absolute value of the input value.

mat_floor

Rounds down the input value.

mat_log

Calculates the logarithm of the input value.

mat_log10

Calculates the logarithm of the input value based on 10.

op_sum

This function sums up the input values.

  • Function format
    op_sum(value1, value2, ...)
  • Description

    Parameter

    Type

    Mandatory

    Description

    value1

    Number or numeric string

    Yes

    Value to be calculated.

    value2

    Number or numeric string

    Yes

    Value to be calculated.

  • Returned result

    The sum of multiple input values.

  • Function example

    Calculate the total price of course_price and goods_price.

    • Test data
      {
       "course_price": 12,
       "goods_price": 2
      }
    • Processing rule
      e_set("account", op_sum(v("course_price"), v("goods_price")))
    • Processing result
      course_price: 12
      goods_price: 2
      account: 14

op_abs

This function performs the absolute value operation on the input value.

  • Function format
    op_abs(value)
  • Description

    Parameter

    Type

    Mandatory

    Description

    value

    Number or numeric string

    Yes

    Value to be calculated.

  • Returned result

    The absolute value of the input value.

  • Function example
    • Test data
      {
       "course_price": -4
      }
    • Processing rule
      e_set("op_abs", op_abs(v("course_price")))
    • Processing result
      course_price: -4
      op_abs: 4

op_div_floor

This function divides the input values exactly.

  • Function format
    op_div_floor(value1, value2)
  • Description

    Parameter

    Type

    Mandatory

    Description

    value1

    Number or numeric string

    Yes

    Value to be calculated.

    value2

    Number or numeric string

    Yes

    Value to be calculated.

  • Returned result

    The result of value 1 divided by value 2.

  • Function example

    Calculate the unit price based on course_price and count.

    • Test data
      {
       "course_price": 4,
       "count": 2
      }
    • Processing rule
      e_set("op_div_floor", op_div_floor(v("course_price"), v("count")))
    • Processing result
      course_price: 4
      count: 2
      op_div_floor: 2

op_div_true

This function divides the input value.

This function supports automatic data type conversion. You can enter data of the string or int type.

  • Function format
    op_div_true(value1, value2)
  • Description

    Parameter

    Type

    Mandatory

    Description

    value1

    Number

    Yes

    Value to be calculated.

    value2

    Number

    Yes

    Value to be calculated.

  • Returned result

    The result of value 1 divided by value 2.

  • Function example
    1. Example 1: Calculate the unit price based on fruit_price and count.
      • Test data
        {
         "fruit_price": 9,
         "count": 2
        }
      • Processing rule
        e_set("op_div_true", op_div_true(v("fruit_price"), v("count")))
      • Processing result
        fruit_price: 9
        count: 2
        op_div_true: 4.5
    2. Example 2: Calculate the acceleration (rounded off). Formula: a = (one_speed – two_speed)/time.
      • Test data
        {
         "one_speed": 9,
         "two_speed": 2,
         "time": 3
        }
      • Processing rule
        e_set("a", op_round(op_div_true(op_sub(v("one_speed"), v("two_speed")), v("time")), 2))
      • Processing result
        a:2.33
        one_speed:9
        time:3
        two_speed:2

op_pow

This function performs exponentiation on a value.

  • Function format
    op_pow(value1, value2)
  • Description

    Parameter

    Type

    Mandatory

    Description

    value1

    Number or numeric string

    Yes

    Value to be calculated.

    value2

    Number or numeric string

    Yes

    Value to be calculated.

  • Returned result

    The result of value 1 raised to the power of value 2.

  • Function example

    Calculate the value of course raised to the power of n.

    • Test data
      {
       "course": 100,
       "pow": 2
      }
    • Processing rule
      e_set("pow_course", op_pow(v("course"), v("pow")))
    • Processing result
      course: 100
      pow: 2
      pow_course: 10000

op_mul

This function multiplies the input values.

  • Function format
    op_mul(value1, value2)
  • Description

    Parameter

    Type

    Mandatory

    Description

    value1

    Number, string, tuple, list, and other

    Yes

    Value to be calculated.

    value2

    Number

    Yes

    Value to be calculated.

  • Returned result
    • Value 1 is of the number type: the result of multiplication of value 1 and value 2
    • Value 1 is of the string, tuple, or list type: a new sequence by repeating value 1 for value 2 times
  • Function example
    1. Example 1: Calculate the total price based on course and price.
      • Test data
        {
         "course": 10,
         "price": 23
        }
      • Processing rule
        e_set("account", op_mul(ct_int(v("course")), ct_int(v("price"))))
      • Processing result
        course: 10
        price: 23
        account: 230
    2. Example 2: Repeat course for three times.
      • Test data
        {
         "course": "abc"
        }
      • Processing rule
        e_set("course", op_mul(v("course"), 3))
      • Processing result
        course: abcabcabc

op_neg

This function calculates the opposite number of the input value.

  • Function format
    op_neg(value)
  • Description

    Parameter

    Type

    Mandatory

    Description

    value

    Number or numeric string

    Yes

    Value to be calculated.

  • Returned result

    The opposite number of the input value

  • Function example
    • Test data
      {
       "course": -100
      }
    • Processing rule
      e_set("account", op_neg(v("course_price")))
    • Processing result
      course: -100
      account: 100

op_mod

This function performs the modulo operation on the input value.

  • Function format
    op_mod(value1, value2)
  • Description

    Parameter

    Type

    Mandatory

    Description

    value1

    Number or numeric string

    Yes

    Value to be calculated.

    value2

    Number or numeric string

    Yes

    Value to be calculated.

  • Returned result

    The result of value 1 modulo value 2

  • Function example
    • Test data
      {
       "course": 4,
       "count": 3
      }
    • Processing rule
      e_set("op_mod", op_mod(v("course"), v("count")))
    • Processing result
      course: 4
      count: 3
      op_mod: 1

op_sub

This function subtracts the input values.

  • Function format
    op_sub(value1, value2)
  • Description

    Parameter

    Type

    Mandatory

    Description

    value1

    Number or numeric string

    Yes

    Value to be calculated.

    value2

    Number or numeric string

    Yes

    Value to be calculated.

  • Returned result

    The result of subtracting value 2 from value 1

  • Function example

    Calculate the result of subtracting count_apple from count.

    • Test data
      {
       "count": 6,
       "count_apple": 3
      }
    • Processing rule
      e_set("sub_number", op_sub(v("count"),v("count_apple")))
    • Processing result
      count: 6
      count_apple: 3
      sub_number:  3

op_round

This function rounds off the input value.

  • Function format
    op_round(value, number)
  • Description

    Parameter

    Type

    Mandatory

    Description

    value

    Number or numeric string

    Yes

    Value to be calculated.

    number

    Number

    Yes

    Number of decimal places reserved after rounding (default value: 0).

  • Returned result

    The rounded result of the input value

  • Function example

    Return the value of price accurate to one decimal place.

    • Test data
      {
       "price": 4.56
      }
    • Processing rule
      e_set("round_price", op_round(v("price"),1))
    • Processing result
      price: 4.56
      round_price: 4.6

mat_ceil

This function rounds up the input value.

  • Function format
    mat_ceil(value)
  • Description

    Parameter

    Type

    Mandatory

    Description

    value

    Number or numeric string

    Yes

    Value to be calculated.

  • Returned result

    The smallest integer greater than or equal to the value

  • Function example
    • Test data
      {
       "price": 4.1
      }
    • Processing rule
      e_set("mat_ceil", mat_ceil(v("price")))
    • Processing result
      price: 4.1
      mat_ceil: 5

mat_exp

This function returns the exponential value with the constant e as the base.

  • Function format
    mat_exp(value)
  • Description

    Parameter

    Type

    Mandatory

    Description

    value

    Number or numeric string

    Yes

    Value to be calculated.

  • Returned result

    The result of e to the power of the value.

  • Function example
    • Test data
      {
       "number": 2
      }
    • Processing rule
      e_set("e_x", mat_exp(v("number")))
    • Processing result
      number: 2
      e_x: 7.38905609893065

mat_fabs

This function calculates the absolute value of the input value.

  • Function format
    mat_fabs(value)
  • Description

    Parameter

    Type

    Mandatory

    Description

    value

    Number or numeric string

    Yes

    Value to be calculated.

  • Returned result

    The absolute value of the input value

  • Function example
    • Test data
      {
       "course_price": -10
      }
    • Processing rule
      e_set("mat_fabs", mat_fabs(v("course_price")))
    • Processing result
      course_price: -10
      mat_fabs: 10.0

mat_floor

This function rounds down the input value.

  • Function format
    mat_floor(value)
  • Description

    Parameter

    Type

    Mandatory

    Description

    value

    Number or numeric string

    Yes

    Value to be calculated.

  • Returned result

    The largest integer that is less than or equal to the value

  • Function example
    • Test data
      {
       "course_price": 4.9
      }
    • Processing rule
      e_set("mat_floor", mat_floor(v("course_price")))
    • Processing result
      course_price: 4.9
      mat_floor: 4

mat_log

This function calculates the logarithm of the input value.

  • Function format
    mat_log(value1,value2)
  • Description

    Parameter

    Type

    Mandatory

    Description

    value1

    Number or numeric string

    Yes

    Value to be calculated.

    value2

    Number or numeric string

    Yes

    Value to be calculated.

  • Returned result

    The logarithm of the input value.

  • Function example
    • Test data
      {
       "number1": 100,
       "number2": 10
      }
    • Processing rule
      e_set("mat_log", mat_log(v("number1"),v("number2")))
    • Processing result
      number1: 100
      number2: 10
      mat_log: 2.0

mat_log10

This function calculates the logarithm of the input value based on 10.

  • Function format
    mat_log10(value)
  • Description

    Parameter

    Type

    Mandatory

    Description

    value

    Number or numeric string

    Yes

    Value to be calculated.

  • Returned result

    The logarithm of the input value with base 10.

  • Function example
    • Test data
      {
       "number": 100
      }
    • Processing rule
      e_set("number2", mat_log10(v("number")))
    • Processing result
      number: 100
      number2: 2.0