Skip to main content Link Search Menu Expand Document (external link)

+ : Addition Operator


On this page

Summary

Adds two numeric values together.

Syntax



Operands

Position Type Description
Left Number First value to add
Right Number Second value to add

Returns

Type: Number (same type as operands, or promoted type)

The sum of the two operands.


Examples

Basic Addition

5
<!-- Output: 8 -->

With Variables

<p>Subtotal: $</p>
<p>Tax: $</p>
<p>Total: $</p>

Data:

doc.Params["model"] = new {
    price = 99.99m,
    tax = 8.00m
};

Output:

<p>Subtotal: $99.99</p>
<p>Tax: $8.00</p>
<p>Total: $107.99</p>

Multiple Additions

<p>Total: </p>

With Formatting

<p>Grand Total: </p>

In #each Loop


  <p>Item : </p>


Precedence

Priority level in expression evaluation: 5 (after *, /, %)


Notes

  • Works with int, long, double, decimal types
  • Mixed types are automatically converted (e.g., int + double = double)
  • Left-to-right associativity: a + b + c = (a + b) + c
  • Use parentheses to control order: (a + b) * c

See Also