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

ceiling(number)

Parameters

NameTypeDescription
numberrealThe 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

['sample-http-logs']
| extend duration_bucket = ceiling(req_duration_ms) * 100
| summarize request_count = count() by duration_bucket
| order by duration_bucket asc

Run in Playground

Output

duration_bucketrequest_count
1001250
2003420
3002180
400890

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

['otel-demo-traces']
| extend duration_seconds = ceiling(duration / 1s)
| summarize avg_duration_seconds = avg(duration_seconds) by ['service.name']
| order by avg_duration_seconds desc

Run in Playground

Output

service.nameavg_duration_seconds
checkout5
product-catalog3
cart2
frontend1

This query rounds span durations up to whole seconds to estimate resource allocation per service.

  • floor: Rounds down to the largest integer less than or equal to the input. Use ceiling when you need to round up instead.
  • bin: Rounds values down to a multiple of a specified bin size. Use ceiling for simple upward rounding to integers.
  • round: Rounds to the nearest integer or specified precision. Use ceiling when you always need to round up.

Other query languages