All Arithmetic functions
Name | Function header | Example | Result | Description | Errorhandling |
---|---|---|---|---|---|
add | func(i …interface{}) int64 | [[ $result := add 600 700 150 650 ) ]] |
$result = int64{2100} | adds two or more numbers and returns and int64 | |
biggest | func(i …interface{}) int64 | [[ $result := biggest 600 700 50 650 ]] |
$result = int64{700} | returns the highest number from one or more numbers | |
ceil | func(a interface{}) float64 | [[ $result := ceil "12.123 ]] |
$result = float64{13} | round up to the next int64 number without fractical part | |
dec | func(i interface{}) int64 | [[ $result := dec "15" ]] |
result = int64{14} | decrement by 1 | |
div | func(a, b interface{}) int64 | [[ $result := div 15 3 ]] |
result = int64{5} | divides a dividend with the divisor | |
floor | func(a interface{}) float64 | [[ $result := floor 13.623 ]] |
result = float64{13} | round down to next int64 number without fractical part | |
inc | func(i interface{}) int64 | [[ $result := dec "15" ]] |
result = int64{16} | increment by 1 | |
max | func(i …interface{}) int64 | [[ $result := max 600 700 50 650 ]] |
$result = int64{700} | returns the highest number one or more numbers | |
min | func(i …interface{}) int64 | [[ $result := min 600 700 50 650 ]] |
$result = int64{50} | returns the lowest number one or more numbers | |
minus | func(a, b interface{}) int64 | [[ $result := minus 16 3 ]] |
$result = int64{13} | substracts the second number (b) from the first number (a) | |
mod | func(a, b interface{}) int64 | [[ $result := mod 16 3 ]] |
$result = int64{1} | contains the remainder of a division | |
mul | func(i …interface{}) int64 | [[ $result := mul 16 3 2 ]] |
$result = int64{96} | multiplies two or more numbers and returns and int64 | |
plus | func(i …interface{}) int64 | [[ $result := plus 600 700 150 650 ]] |
$result = int64{2100} | adds two or more numbers and returns and int64 | |
round | func(a float64) float64 | [[ $result := round ( float64 ( "12.5" ) ) ]] [[ $result := round ( float64 ( "12.49" ) ) ]] |
\$result = int64{13} \$result = int64{12} |
rounds up or down the number | |
sub | func(a, b interface{}) int64 | [[ $result := sub 16 3 ]] |
$result = int64{13} | substracts the second number (b) from the first number (a) |
func(i ...interface{}) int64
The add
function adds two or more numbers and returns and int64.
Examples
[[ $result := toString (add 600 700 150 650 ) ]]
$result = "2100"
result is an object of int64
[[ $result := add 600 700 150 650 ]]
$result = int64{2100}
complex example: testnumbers contains "1200, 500, 300"
[[ $interface := getCurrentRequestDataValues "testnumbers" ]]
[[ $result := 0 ]]
[[ range $v := $interface ]]
[[ $result = add $result $v ]]
[[ end ]]
[[ $result := toString $result ]]
$result = 2000
See chapter max in this document.
func(a interface{}) float64
The ceil
function rounds up the number to the next int64.
Examples
[[ $result := toString ( ceil "12.123" ) ]]
$result = "13"
result is an object of float64
[[ $result := ceil "12.123" ]]
$result = float64{13}
func(i interface{}) int64
The dec
function decrements by 1.
Examples
[[ $result := toString ( dec "15" ) ]]
result = "14"
result is an object of int64
[[ $result := dec "15" ]]
result = int64{14}
func(a, b interface{}) int64
The div
function divides a dividend with the divisor.
The result always is a number without decimal value. The result is presented as int64-value.
Application notes / Limits:
Examples
[[ $result := toString ( div 15 3 ) ]]
result = "5"
result is an object of int64
[[ $result := toString ( div 15 3 ) ]]
result = int64{5}
result is an object of int64 and and quotient (answer) contains a value without decimal/fractial values.
[[ $result := toString ( div 12 5 ) ]]
result = int64{2}
func(a interface{}) float64
The floor
function rounds down the number to the next int64
Examples
[[ $result := toString ( floor "13.623" ) ]]
result = "13"
[[ $result := toString ( floor 13.623 ) ]]
result = "13"
result is an object of float64
[[ $result := floor 13.623 ]]
result = float64{13}
Console result
[[ floor 13.623 ]]
result = "13"
func(i interface{}) int64
The inc
function increments by 1
Examples
[[ $result := toString ( dec "15" ) ]]
result = "16"
result is an object of int64
[[ $result := dec "15" ]]
result = int64{16}
func(i ...interface{}) int64
The max
function returns the highest number from two or more numbers
Examples
[[ $result := toString (biggest (add 600 700 50 650 )) ]]
$result = "700"
result is an object of int64
[[ $result := max 600 700 50 650 ]]
$result = int64{700}
complex example: testnumbers contains "300, 500, 1200"
[[ $interface := getCurrentRequestDataValues "testnumbers" ]]
[[ $result := 0 ]]
[[ range $v := $interface ]]
[[ $result = max $result $v ]]
[[ end ]]
[[ $result := toString $result ]]
[[ setCurrentResultDataValue "TestresultDyn" $result ]]
$result = "1200"
func(i ...interface{}) int64
The min
function returns the lowest number of two or more numbers
Examples
[[ $result := toString (min 600 700 50 650 ) ]]
$result = "50"
result is an object of int64
[[ $result := min 600 700 50 650 ]]
$result = int64{50}
complex example with 2 loops/ranges. frist: get highest number, second: get lowest number: testnumbers contains "300, 500, 1200"
[[ $interface := getCurrentRequestDataValues "testnumbers" ]]
_comment step1: get highest number
[[ $interface := getCurrentRequestDataValues "testnumbers" ]]
[[ $result := 0 ]]
[[ range $v := $interface ]]
[[ $result = max $result $v ]]
[[ end ]]
_comment step2: get lowest number now
[[ range $v := $interface ]]
[[ $result = min $result $v ]]
[[ end ]]
[[ $result := toString $result ]]
[[ setCurrentResultDataValue "TestresultDyn" $result ]]
$result = "300"
func(a, b interface{}) int64
The minus
function substracts the second number (b) from the first number (a).
If the second number is larger then the first number, the result will have a minus in front of the number.
Application notes / Limits:
Examples
[[ $result := toString ( minus 16 3 ) ]]
$result= "13"
result is an object of int64
[[ $result := minus 16 3 ]]
$result = int64{13}
[[ $result := toString ( minus 15 18 ) ]]
$result= "-3"
[[ $result := toString ( minus 15 15 ) ]]
$result= "0"
not working example
[[ $result := toString ( minus 15.5 2.3 ) ]]
$result= "0"
func(a, b interface{}) int64
The mod
function mod (modular) function contains the remainder of a division, after one number is divided by another number.
e.g. 10 / 3 = 3 remainer 1
Application notes / Limits:
Examples
[[ $result := toString ( mod 16 3 ) ]]
$result = "1"
result is an object of int64
[[ $result := mod 16 3 ]]
$result = int64{1}
[[ $result := toString ( mod 16 4 ) ]]
$result = "0"
[[ $result := toString ( mod 16 12 ) ]]
$result = "4"
References
func(i ...interface{}) int64
The mul
function mul (multiplication) multiplies two or more numbers.
Application notes / Limits:
Examples
[[ $result := toString ( mul 16 3 2 ) ]]
$result = "96"
result is an object of int64
[[ $result := mul 16 3 2 ]]
$result = int64{96}
complex example: testnumbers contains "300, 501, 1200"
[[ $interface := getCurrentRequestDataValues "testnumbers" ]]
[[ $result := 1 ]]
[[ range $v := $interface ]]
[[ $result = mul $result $v ]]
[[ end ]]
[[ $result := toString $result ]]
[[ setCurrentResultDataValue "TestresultDyn" $result ]]
$result = "180360000"
func(i ...interface{}) int64
The plus
function adds two or more numbers and returns and int64.
See also function add
Application notes / Limits:
Examples
[[ $result := toString ( plus 600 700 150 650 ) ]]
$result = "2100"
result is an object of int64
[[ $result := plus 600 700 150 650 ]]
$result = int64{2100}
complex example: testnumbers contains "300, 501, 1200"
[[ $interface := getCurrentRequestDataValues "testnumbers" ]]
[[ $result := 0 ]]
[[ range $v := $interface ]]
[[ $result = plus $result $v ]]
[[ end ]]
[[ $result := toString $result ]]
[[ setCurrentResultDataValue "TestresultDyn" $result ]]
$result = "2001"
func(a float64) float64
The round
function rounds up or down the number, depending on the fractial part.
Application notes / Limits:
Examples
[[ $result := toString ( round ( float64 ( "12.49" ) ) ) ]]
$result = "12"
[[ $result := toString ( round ( float64 ( "12.5" ) ) ) ]]
$result = "13"
result is an object of int64
[[ $result := round ( float64 ( "12.5" ) ) ]]
$result = int64{13}
See function minus