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

/ : 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

<p>Average: </p>

Data:

doc.Params["model"] = new {
    total = 487.50m,
    count = 5
};

Output:

<p>Average: $97.50</p>

Unit Price

<p>Price per unit: $</p>

Data:

doc.Params["model"] = new {
    totalPrice = 149.99m,
    quantity = 12
};

Output:

<p>Price per unit: $12.50</p>

Percentage Calculation

<p>Completion: %</p>

Data:

doc.Params["model"] = new {
    completed = 17,
    total = 25
};

Output:

<p>Completion: 68.0%</p>

Rate Calculation

<p>Speed:  mph</p>

Ratio Comparison

<p>Efficiency Ratio: </p>


  <span class="excellent">Highly efficient</span>

  <span class="good">Efficient</span>

  <span class="poor">Needs improvement</span>


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(), or floor() 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