This topic describes the syntax, description, parameters, return values, and examples of numeric functions.

add

This function is described as follows:
  • Syntax: add(n1, n2)
  • Description

    You can call this function to compute the sum of two addends.

  • Parameters
    • n1: the first addend.
    • n2: the second addend.
  • Return values

    This function returns the sum of n1 + n2.

  • Examples
    n1 = add(10, 20)
    n2 = sub(10, 20)
    n3 = mul(10, 20)
    n4 = div(10, 20)
    n5 = mod(35, 20)
    say(concat('n1=', n1))
    say(concat('n2=', n2))
    say(concat('n3=', n3))
    say(concat('n4=', n4))
    say(concat('n5=', n5))
    
    Output:
    n1=30
    n2=-10
    n3=200
    n4=0.5
    n5=15

sub

This function is described as follows:
  • Syntax: sub(n1, n2)
  • Description

    You can call this function to compute the difference between two numbers.

  • Parameters
    • n1: the minuend.
    • n2: the subtrahend.
  • Return values

    This function returns the difference of n1 - n2.

  • Examples
    n1 = add(10, 20)
    n2 = sub(10, 20)
    n3 = mul(10, 20)
    n4 = div(10, 20)
    n5 = mod(35, 20)
    say(concat('n1=', n1))
    say(concat('n2=', n2))
    say(concat('n3=', n3))
    say(concat('n4=', n4))
    say(concat('n5=', n5))
    
    Output:
    n1=30
    n2=-10
    n3=200
    n4=0.5
    n5=15

mul

This function is described as follows:
  • Syntax: mul(n1, n2)
  • Description

    You can call this function to compute the product of two numbers.

  • Parameters
    • n1: the multiplicand.
    • n2: the multiplier.
  • Return values

    This function returns the product of n1 × n2.

  • Examples
    n1 = add(10, 20)
    n2 = sub(10, 20)
    n3 = mul(10, 20)
    n4 = div(10, 20)
    n5 = mod(35, 20)
    say(concat('n1=', n1))
    say(concat('n2=', n2))
    say(concat('n3=', n3))
    say(concat('n4=', n4))
    say(concat('n5=', n5))
    
    Output:
    n1=30
    n2=-10
    n3=200
    n4=0.5
    n5=15

div

This function is described as follows:
  • Syntax: div(n1, n2)
  • Description

    You can call this function to compute the quotient of two numbers.

  • Parameters
    • n1: the dividend.
    • n2: the divisor.
  • Return values

    This function returns the quotient of n1/n2.

  • Examples
    n1 = add(10, 20)
    n2 = sub(10, 20)
    n3 = mul(10, 20)
    n4 = div(10, 20)
    n5 = mod(35, 20)
    say(concat('n1=', n1))
    say(concat('n2=', n2))
    say(concat('n3=', n3))
    say(concat('n4=', n4))
    say(concat('n5=', n5))
    
    Output:
    n1=30
    n2=-10
    n3=200
    n4=0.5
    n5=15

mod

This function is described as follows:
  • Syntax: mod(n1, n2)
  • Description

    You can call this function to compute the remainder after division of one number by another.

  • Parameters
    • n1: the dividend.
    • n2: the divisor.
  • Return values

    This function returns the remainder of n1 % n2.

  • Examples
    n1 = add(10, 20)
    n2 = sub(10, 20)
    n3 = mul(10, 20)
    n4 = div(10, 20)
    n5 = mod(35, 20)
    say(concat('n1=', n1))
    say(concat('n2=', n2))
    say(concat('n3=', n3))
    say(concat('n4=', n4))
    say(concat('n5=', n5))
    
    Output:
    n1=30
    n2=-10
    n3=200
    n4=0.5
    n5=15

gt

This function is described as follows:
  • Syntax: gt(n1, n2)
  • Description

    You can call this function to determine whether a number is greater than another number.

  • Parameters
    • n1: the number to be compared.
    • n2: the number used to compare.
  • Return values

    This function returns true if n1 > n2. Otherwise, it returns false.

  • Examples
    if and($arg_num, gt(tonumber($arg_num), 10)) {
        say('num > 10')
    }                                                                                                                                                                                                      
    if and($arg_num, ge(tonumber($arg_num), 10)) {
        say('num >= 10')
    }
    if and($arg_num, lt(tonumber($arg_num), 10)) {
        say('num < 10')
    }                                                                                                                                                                                                       
    if and($arg_num, le(tonumber($arg_num), 10)) {
        say('num <= 10')
    }
    
    Request: /path1/path2/file? num=10  Response: num <= 10   num >= 10
    Request: /path1/path2/file? num=11  Response: num > 10    num >= 10
    Request: /path1/path2/file? num=9   Response: num < 10    num <= 10

ge

This function is described as follows:
  • Syntax: ge(n1, n2)
  • Description

    You can call this function to determine whether a number is greater than or equal to another number.

  • Parameters
    • n1: the number to be compared.
    • n2: the number used to compare.
  • Return values

    This function returns true if n1 >= n2. Otherwise, it returns false.

  • Examples
    if and($arg_num, gt(tonumber($arg_num), 10)) {
        say('num > 10')
    }                                                                                                                                                                                                      
    if and($arg_num, ge(tonumber($arg_num), 10)) {
        say('num >= 10')
    }
    if and($arg_num, lt(tonumber($arg_num), 10)) {
        say('num < 10')
    }                                                                                                                                                                                                       
    if and($arg_num, le(tonumber($arg_num), 10)) {
        say('num <= 10')
    }
    
    Request: /path1/path2/file? num=10  Response: num <= 10   num >= 10
    Request: /path1/path2/file? num=11  Response: num > 10    num >= 10
    Request: /path1/path2/file? num=9   Response: num < 10    num <= 10

lt

This function is described as follows:
  • Syntax: lt(n1, n2)
  • Description

    You can call this function to determine whether a number is less than another number.

  • Parameters
    • n1: the number to be compared.
    • n2: the number used to compare.
  • Return values

    This function returns true if n1 < n2. Otherwise, it returns false.

  • Examples
    if and($arg_num, gt(tonumber($arg_num), 10)) {
        say('num > 10')
    }                                                                                                                                                                                                      
    if and($arg_num, ge(tonumber($arg_num), 10)) {
        say('num >= 10')
    }
    if and($arg_num, lt(tonumber($arg_num), 10)) {
        say('num < 10')
    }                                                                                                                                                                                                       
    if and($arg_num, le(tonumber($arg_num), 10)) {
        say('num <= 10')
    }
    
    Request: /path1/path2/file? num=10  Response: num <= 10   num >= 10
    Request: /path1/path2/file? num=11  Response: num > 10    num >= 10
    Request: /path1/path2/file? num=9   Response: num < 10    num <= 10

le

This function is described as follows:
  • Syntax: le(n1, n2)
  • Description

    You can call this function to determine whether a number is less than or equal to another number.

  • Parameters
    • n1: the number to be compared.
    • n2: the number used to compare.
  • Return values

    This function returns true if n1 <= n2. Otherwise, it returns false.

  • Examples
    if and($arg_num, gt(tonumber($arg_num), 10)) {
        say('num > 10')
    }                                                                                                                                                                                                      
    if and($arg_num, ge(tonumber($arg_num), 10)) {
        say('num >= 10')
    }
    if and($arg_num, lt(tonumber($arg_num), 10)) {
        say('num < 10')
    }                                                                                                                                                                                                       
    if and($arg_num, le(tonumber($arg_num), 10)) {
        say('num <= 10')
    }
    
    Request: /path1/path2/file? num=10  Response: num <= 10   num >= 10
    Request: /path1/path2/file? num=11  Response: num > 10    num >= 10
    Request: /path1/path2/file? num=9   Response: num < 10    num <= 10

floor

This function is described as follows:
  • Syntax: floor(n)
  • Description

    You can call this function to generate the greatest integer less than or equal to a number.

  • Parameters

    n1: the number to be rounded up.

  • Return values

    This function returns the greatest integer less than or equal to the specified n parameter.

  • Examples
    if $arg_num {
        say(concat('ceil: ', ceil(tonumber($arg_num))))
        say(concat('floor: ', floor(tonumber($arg_num))))
    }
    
    Request: /path1/path2/file? num=9.3  Response: ceil: 10   floor: 9

ceil

This function is described as follows:
  • Syntax: ceil(n).
  • Description

    You can call this function to generate the least integer greater than or equal to a number.

  • Parameters

    n1: the number to be rounded down.

  • Return values

    This function returns the least integer greater than or equal to the specified n parameter.

  • Examples
    if $arg_num {
        say(concat('ceil: ', ceil(tonumber($arg_num))))
        say(concat('floor: ', floor(tonumber($arg_num))))
    }
    
    Request: /path1/path2/file? num=9.3  Response: ceil: 10   floor: 9