# Basic Math in Templates

Rally extensively supports mathematical operations within templates.

Basic operations (add, subtract, multiple and divide) can be completed using the +, -, * and / symbols.

`{ 1 + 1 }`

This would output "2" in the document.

Formula With Variable

`{ 2 * (purchasePrice + 1) }`

This would add 1 to purchase_price and multiple the result by 2. If "purchase_price" were 100, then "202" would be output in the document.

Filters

Filters can also be used to manipulate numerical outputs. For example, if you wanted a number to be output as a currency, you could use the currency filter:

`{ purchasePrice | currency }`

If purchase price was "100", this would output 100.00 to the document.

More information on what filters are available can be found in: Using Filters When Encoding Documents

Note that to put a dollar sign before the currency, you would need to prepend the curly braces with a dollar sign:

`\${ purchasePrice | currency }`

This would out put "\$100.00" if purchase_price was 100.

Assigning Values to Variables

You may also assign values to new variables:

`{ totalPrice = purchasePrice * (1 + taxRate) }`

This would assign the value of the equation to total_price, which you could then use later in multiple places within the template. 