9. Other Features and Miscellany

9.1 Math

Velocity has a number of built-in mathematical functions that can be used in templates with the set directive. The following equations are examples of addition, subtraction, multiplication and division, respectively:

#set( $foo = $bar + 3 )
#set( $foo = $bar - 4 )
#set( $foo = $bar * 6 )
#set( $foo = $bar / 2 )

When a division operation is performed between two integers, the result will be an integer. Any remainder can be obtained by using the modulus (%) operator.

#set( $foo = $bar % 5 )