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

add

The following table describes the details about this function.
ItemDescription
Syntaxadd(n1, n2)
DescriptionCalculates the sum of two addends.
Parameter
  • n1: the addend.
  • n2: the other addend.
Return valueReturns the sum of n1 + n2.
Example
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

The following table describes the details about this function.
ItemDescription
Syntaxsub(n1, n2)
DescriptionCalculates the difference between two numbers.
Parameter
  • n1: the (minuend) number to be subtracted from.
  • n2: the (subtrahend) number to be subtracted.
Return valueReturns the difference of n1 - n2.
Example
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

The following table describes the details about this function.
ItemDescription
Syntaxmul(n1, n2)
DescriptionCalculates the product of two numbers.
Parameter
  • n1: the multiplicand.
  • n2: the other multiplicand.
Return valueReturns the product of n1 × n2.
Example
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

The following table describes the details about this function.
ItemDescription
Syntaxdiv(n1, n2)
DescriptionCalculates the quotient of two numbers.
Parameter
  • n1: the dividend.
  • n2: the divisor.
Return valueReturns the quotient of n1/n2.
Example
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

The following table describes the details about this function.
ItemDescription
Syntaxmod(n1, n2)
DescriptionCalculates the remainder after division of one number by another.
Parameter
  • n1: the dividend.
  • n2: the divisor.
Return valueReturns the remainder of n1 % n2.
Example
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

The following table describes the details about this function.
ItemDescription
Syntaxgt(n1, n2)
DescriptionDetermines whether a number is greater than another one.
Parameter
  • n1: the number to be compared.
  • n2: the other number to be compared.
Return valueIf n1 > n2, true is returned. Otherwise, false is returned.
Example
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

The following table describes the details about this function.
ItemDescription
Syntaxge(n1, n2)
DescriptionDetermines whether a number is greater than or equal to another one.
Parameter
  • n1: the number to be compared.
  • n2: the other number to be compared.
Return valueIf n1 >= n2, true is returned. Otherwise, false is returned.
Example
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

The following table describes the details about this function.
ItemDescription
Syntaxlt(n1, n2)
DescriptionDetermines whether a number is smaller than another one.
Parameter
  • n1: the number to be compared.
  • n2: the other number to be compared.
Return valueIf n1 < n2, true is returned. Otherwise, false is returned.
Example
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

The following table describes the details about this function.
ItemDescription
Syntaxle(n1, n2)
DescriptionDetermines whether a number is smaller than or equal to another one.
Parameter
  • n1: the number to be compared.
  • n2: the other number to be compared.
Return valueif n1 <= n2, true is returned. Otherwise, false is returned.
Example
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

The following table describes the details about this function.
ItemDescription
Syntaxfloor(n)
DescriptionGenerates the greatest integer that is smaller than or equal to a number.
Parametern: the number to be rounded down.
Return valueReturns the greatest integer that is smaller than or equal to the number specified byn.
Example
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

The following table describes the details about this function.
ItemDescription
Syntaxceil(n)
DescriptionGenerates the smallest integer that is greater than or equal to a number.
Parametern: the number to be rounded up.
Return valueReturns the smallest integer that is greater than or equal to the number specified byn.
Example
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.