ez.no / exponential / documentation / development / libraries / ez template / operators / arithmetics
These documentation pages are no longer maintained. Please visit the new documentation site.
Returns the sum of all parameters, including the input parameter if it is used.
sum( $a, $b, $c ) equal $a + $b + $c
and
$a|sum( $b, $c, $d ) equal $a + $b + $c + $d
Subtracts all extra parameters from the first parameter, e.g.
sub( $a, $b, $c ) equal $a - $b - $c
If an input parameter is supplied that will be considered the first element and the parameters the subtractors, e.g.
$a|sub( $b, $c, $d ) equal $a - $b - $c - $d
Increases either the input value or the first parameter with one. e.g.
{set i=$i|inc}
and
{set i=inc( $i )}
Decreases either the input value or the first parameter with one
e.g.
{set i=$i|dec}
and
{set i=dec( $i )}
Divides all extra parameters with the first parameter, e.g.
div( $a, $b, $c ) equal $a / $b / $c
If an input parameter is supplied that will be considered the dividend and the parameters will the divisors, e.g.
$a|div( $b, $c, $d ) equal $a / $b / $c / $d
Returns the modulo of the first input parameter divided by the second. E.g.
mod( 5, 3 )
returns 2.
Multiplies all parameters and returns the result, if an input parameter
is supplied it will be included in the multiplication, e.h.
mul( $a, $b, $c ) equal $a * $b * $c
and
$a|mul( $b, $c ) equal $a * $b * $c
Returns the largest value of all parameters, e.g.
max( 2, 3, 1 )
returns 3
Returns the smallest value of all parameters, e.g.
min( 2, 3, 1 )
returns 1
Returns a positive value of either the input value or the first parameter. e.g.
{abs(-1)}
,
{-1|abs}
returns 1 and
{abs(200)}
returns 200.
Returns the next highest integer value by rounding up input value if necessary, e.g.
{ceil(1.2)}
returns 2
Returns the next lowest integer value by rounding down input value if necessary, e.g.
{floor(1.2)}
returns 1
Returns the rounded value of input value, e.g.
{round(1.2)}
returns 1, and
{round(1.6)}
returns 2
Returns the count of the input value.
How counts are interpreted:
- If the data is an array the array count is used
- If the data is an object the object attribute count is used
- If the data is a string the string length is used
- If the data is a numeric the value is used
- If the data is a boolean false is 0 and true is 1
- For all other data 0 is used
e.g.
{array( 1, 2, 5 )|count}
returns 3
Comments