/ : Division Operator
On this page
Summary
Divide one numeric value by another.
Syntax
Precedence
Priority level in expression evaluation (1 = highest, 10 = lowest): 4
Evaluated after: ^
Evaluated before: +, -, <, <=, >, >=, ==, !=, ??, &&, ||
Operands
| Position | Type | Description |
|---|---|---|
| Left | Number | Dividend (value to be divided) |
| Right | Number | Divisor (value to divide by) |
Returns
Type: Number (Double or Decimal depending on operands)
The quotient of the left operand divided by the right operand.
Examples
Average Calculation
Data:
doc.Params["model"] = new {
total = 487.50m,
count = 5
};
Output:
<p>Average: $97.50</p>
Unit Price
Data:
doc.Params["model"] = new {
totalPrice = 149.99m,
quantity = 12
};
Output:
<p>Price per unit: $12.50</p>
Percentage Calculation
Data:
doc.Params["model"] = new {
completed = 17,
total = 25
};
Output:
<p>Completion: 68.0%</p>
Rate Calculation
Ratio Comparison
Notes
- Works with all numeric types (int, long, double, decimal)
- Result is typically a decimal or double for precision
- Division by zero will throw an error
- Use
round(),ceiling(), orfloor()to control decimal places - For integer division (with remainder), use
%(modulus) operator - Division has same precedence as multiplication
- Use parentheses to control order of operations
See Also
- Multiplication Operator
- Modulus Operator
- round Function
- ceiling Function
- floor Function
- format Function