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

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

<p>Rounded Price: $</p>

Data:

doc.Params["model"] = new {
    price = 19.01m
};

Output:

<p>Rounded Price: $20</p>

Calculate Pages Needed

<p>Pages required: </p>

Data:

doc.Params["model"] = new {
    items = 47,
    itemsPerPage = 10
};

Output:

<p>Pages required: 5</p>

Minimum Purchase Quantity

<p>Boxes needed: </p>

Data:

doc.Params["model"] = new {
    quantity = 38,
    boxSize = 12
};

Output:

<p>Boxes needed: 4</p>

Always Round Up


  <li></li>

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

See Also