ceiling() : Round Up to Integer
On this page
Summary
Round a number up to the nearest integer.
Signature
ceiling(value)
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
value |
Number | Yes | The number to round up |
Returns
Type: Integer
The smallest integer greater than or equal to the value.
Examples
Round Up Prices
Data:
doc.Params["model"] = new {
price = 19.01m
};
Output:
<p>Rounded Price: $20</p>
Calculate Pages Needed
Data:
doc.Params["model"] = new {
items = 47,
itemsPerPage = 10
};
Output:
<p>Pages required: 5</p>
Minimum Purchase Quantity
Data:
doc.Params["model"] = new {
quantity = 38,
boxSize = 12
};
Output:
<p>Boxes needed: 4</p>
Always Round Up
Data:
doc.Params["model"] = new {
values = new[] { 1.1, 2.5, 3.9, 4.0 }
};
Output:
<li>1.1 → 2</li>
<li>2.5 → 3</li>
<li>3.9 → 4</li>
<li>4.0 → 4</li>
Notes
- Always rounds up (towards positive infinity)
- Returns integer type
- For down rounding, use
floor() - For nearest rounding, use
round() - For removing decimals without rounding, use
truncate() - Negative numbers round towards zero:
-1.5→-1