mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 21:00:22 -07:00
math filters!
This commit is contained in:
parent
fbadcfd44f
commit
7a43d40050
2 changed files with 135 additions and 0 deletions
|
@ -310,6 +310,45 @@ To get a random list from an existing list::
|
|||
{{ ['a','b','c']|shuffle }} => ['b','c','a']
|
||||
|
||||
note that when used with a non 'listable' item it is a noop, otherwise it always returns a list
|
||||
j
|
||||
|
||||
.. _math_stuff:
|
||||
|
||||
Math
|
||||
--------------------
|
||||
.. versionadded:: 1.9
|
||||
|
||||
To get the absolute value of a number::
|
||||
|
||||
{{ -23 | abs }}
|
||||
|
||||
To see if something is actually a number::
|
||||
|
||||
{{ myvar | isnan }}
|
||||
|
||||
Rounding::
|
||||
|
||||
{{ myvar | ceil }}
|
||||
{{ myvar | floor }}
|
||||
|
||||
Get the logarithm (default is e)::
|
||||
|
||||
{{ myvar | log }}
|
||||
|
||||
Get the base 10 logarithm::
|
||||
|
||||
{{ myvar | log(10) }}
|
||||
|
||||
Give me the power of 2! (or 5)::
|
||||
|
||||
{{ myvar | pow(2) }}
|
||||
{{ myvar | pow(5) }}
|
||||
|
||||
Square root, or the 5th::
|
||||
|
||||
{{ myvar | root }}
|
||||
{{ myvar | root(5) }}
|
||||
|
||||
|
||||
.. _other_useful_filters:
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue