Math
Name | Description | Function arguments | Usage |
---|---|---|---|
round | Rounds the float value to nearest integer value | round(myFloat) | {{ round 100.456 }} |
roundToEven | Rounds to the nearest integer, rounding ties to even. | roundToEven(myFloat) | {{ round 100.456 }} |
roundTo | Round to the nearest requested precision point. | roundTo(myFloat, decimalPlaces) | {{ roundTo 100.456 2 }} |
roundToAndHumanize | Round to the nearest requested precision point and add comma separation for thousands. | roundToAndHumanize(myFloat, decimalPlaces) | {{ roundToAndHumanize 100.456 2 }} |
roundToAndHumanizeWithConf | Same as roundToAndHumanize, but with configuration options. E.g " ," will apply space to thousand separator and comma to decimal separator |
roundToAndHumanizeWithConf(myFloat, decimalPlaces, " ,") | {{ roundToAndHumanizeWithConf 100.456 2 “,.” }} |
roundAndFormatTo1f | Round to 1 decimal. | roundAndFormatTo1f(myFloat) | {{ roundAndFormatTo1f 100.456 }} |
roundAndFormatTo2f | Round to 2 decimals. | roundAndFormatTo2f(myFloat) | {{ roundAndFormatTo2f 100.456 }} |
roundAndFormatTo3f | Round to 3 decimals. | roundAndFormatTo3f(myFloat) | {{ roundAndFormatTo3f 100.456 }} |
roundAndFormatTo4f | Round to 4 decimals. | roundAndFormatTo4f(myFloat) | {{ roundAndFormatTo4f 100.456 }} |
toAbsolute | Convert to absolute value | toAbsolute(myValue) | {{ toAbsolute -100.456 }} |
removeZeroes | Remove trailing zeroes. Example: 100.0500 -> 100.05 | removeZeroes(myFloat) | {{ removeZeroes -100.4560000 }} |
humanize | Add comma separation to thousands. Example: 100000.00 -> 100,000.00 | humanize(myFloat) | {{ humanize 100.456 }} |
humanizeWithConf | Same as humanize, but with configuration options. E.g " ," will apply space to thousand separator and comma to decimal separator |
humanizeWithConf(myFloat, decimals, " ,") | {{ humanizeWithConf 100.456 2 “,.” }} |
add | Adds all the input parameters. Can define as many parameters as needed. | add(myVal1, myVal2, …) | {{ add -100.4560000 1 3 }} |
subtract | Subtracts the input parameters from 0. Can define as many parameters as needed. | subtract(myVal1, myVal2, …) | {{ subtract -100.4560000 1 3 }} |
subtractFrom | Subtracts the input parameters from specified value. Can define as many parameters as needed. | subtractFrom(initialVal, myVal1, myVal2, …) | {{ subtractFrom -100.4560000 1 3 }} |
divide | Divides the input parameters. Can define as many parameters as needed. Note that 0 values are ignored. | divide(myVal1, myVal2, …) | {{ divide -50 1 }} |
div | Divide 2 exact values | div(val1, val2) | {{ div -50 1 }} |
multiply | Multiplies the input parameters. Can define as many parameters as needed. Note that 0 values are ignored. | multiply(myVal1, myVal2, …) | {{ multiply -50 1 }} |
mul | Multiply 2 exact values | mul(val1, val2) | {{ mul -50 1 }} |
pow | Calculates the parameter 1 to the power parameter 2 power | pow(myFloat1, myFloat2) | {{ pow 1.1 1.2 }} |
ceil | Round a floating point value up to the nearest integer | ceil(myFloat1) | {{ ceil 1.1 }} |
floor | Returns the greatest integer value less than or equal to x. | floor(myFloat1) | {{ floor 1.1 }} |
As with the functions that accept a single parameter the same applies here that they can also be used with the pipe notation.
{{ 13.6 | roundToEven }}
{{ 13.6 | round }}