CEIL()

All functions > MATH > CEIL()

Returns the smallest integer greater than or equal to the input.

Signatures

Ceiling of a floating-point number

Returns: Smallest integer ≥ input

CEIL(number: T) → BIGINT
sql
ParameterTypeRequiredDescription
numberTYesThe number to round up

With:

  • T : Custom types: FLOAT | DOUBLE

Signature notes:

  • Always rounds toward positive infinity
  • FLOAT and DOUBLE return BIGINT. DECIMAL(p, s) returns DECIMAL(p - s + min(s, 1), 0). A value outside the result range fails when the query runs
  • Returns NULL if the input is NULL
  • For exact integer values, returns the same value

Ceiling of a decimal

Returns: DECIMAL(p - s + min(s, 1), 0), the smallest decimal at that scale that is ≥ the input

CEIL(number: DECIMAL) → DECIMAL
sql
ParameterTypeRequiredDescription
numberDECIMALYesThe decimal to round up

Examples

FeatureQL
RETURN
    -- Positive rounds up
    f1 := CEIL(2.1e0),
    -- Another positive
    f2 := CEIL(2.9e0),
    -- Negative rounds toward zero
    f3 := CEIL(-2.1e0),
    -- Negative closer to integer
    f4 := CEIL(-2.9e0),
    -- Exact integer unchanged
    f5 := CEIL(5.0e0),
    -- Pi rounds up to 4
    f6 := CEIL(3.14159e0)
;
Result
f1 BIGINTf2 BIGINTf3 BIGINTf4 BIGINTf5 BIGINTf6 BIGINT
33-2-254