Arithmetic functions

Arithmetic functions are used to perform basic calculations on values.

Add

The + (addition) function is used to find the sum of two argument expressions.

Format

{%= double + double %}

Example

The following operation sums the price of two different products.

{%= product1.price + product2.price %}

Multiply

The * (multiplication) function is used to find the product of two argument expressions.

Format

{%= double * double %}

Example

The following operation finds the product of the inventory and the price of a product to find the gross value of the product.

{%= product.inventory * product.price %}

Subtract

The - (subtraction) function is used to find the difference of two argument expressions.

Format

{%= double - double %}

Example

The following operation finds the difference in price between two different products.

{%= product1.price - product2.price %}

Divide

The / (division) function is used to find the quotient of two argument expressions.

Format

{%= double / double %}

Example

The following operation finds the quotient between the total products sold and total money earned to see the average cost per item.

{%= totalProduct.price / totalProduct.sold %}

Remainder

The % (modulo/remainder) function is used to find the remainder after dividing the two argument expressions.

Format

{%= double % double %}

Example

The following operation checks if the person’s age is divisible by five.

{%= person.age % 5 = 0 %}

On this page