ceiling
This page explains how to use the ceiling function in APL.
Use the ceiling function to round a numeric value up to the smallest integer greater than or equal to the input. This function is useful when you need to ensure that fractional values always round up, such as when calculating resource allocations, pagination counts, or bucket sizes.
Use ceiling when you want to convert decimal numbers to whole numbers by rounding up. For example, if you have 7.2 requests per second and need to provision whole server instances, ceiling ensures you allocate 8 instances rather than 7.
Usage
Syntax
Parameters
| Name | Type | Description |
|---|---|---|
number | real | The numeric value to round up. |
Returns
An integer representing the smallest whole number greater than or equal to the input value.
Use case examples
Round request durations up to whole milliseconds for consistent bucketing.
Query
Output
| duration_bucket | request_count |
|---|---|
| 100 | 1250 |
| 200 | 3420 |
| 300 | 2180 |
| 400 | 890 |
This query groups requests into 100ms buckets using ceiling to ensure all fractional durations round up to the next bucket boundary.
Calculate the minimum number of seconds to allocate for trace processing.
Query
Output
| service.name | avg_duration_seconds |
|---|---|
| checkout | 5 |
| product-catalog | 3 |
| cart | 2 |
| frontend | 1 |
This query rounds span durations up to whole seconds to estimate resource allocation per service.
List of related functions
- floor: Rounds down to the largest integer less than or equal to the input. Use
ceilingwhen you need to round up instead. - bin: Rounds values down to a multiple of a specified bin size. Use
ceilingfor simple upward rounding to integers. - round: Rounds to the nearest integer or specified precision. Use
ceilingwhen you always need to round up.