Function ceil()
📝 Description
The ceil function (short for "ceiling") returns the closest whole number that is greater than or equal to the given value. It effectively "rounds up" to the nearest integer.
Use Case: Essential for capacity planning. If your calculation says you need
2.1virtual machines,ceilwill ensure you provision3.
💻 Syntax
💡 Examples
1. Basic Rounding Up:
2. Negative Numbers (Be Careful!):
In the negative scale, the "greater" number is the one closer to zero.
3. Capacity Calculation (Real-world scenario):
If you want to provision 1 CPU for every 4GB of RAM, and you have 10GB:
⚠️ Comparison Table
| Input | ceil() (Up) | floor() (Down) |
|---|---|---|
1.1 |
2 | 1 |
1.9 |
2 | 1 |
2.0 |
2 | 2 |
-1.5 |
-1 | -2 |
🔗 Related Functions
-
[[abs]] — Get the positive value.
-
[[floor]] — Round down to the nearest integer.