ceiling function

The fn:ceiling function returns the smallest integer that is greater than or equal to a specific numeric value.

Syntax

Read syntax diagramSkip visual syntax diagramfn:ceiling( numeric-value)
numeric-value
An atomic value or an empty sequence.
If numeric-value is an atomic value, it has one of the following types:
  • xs:float
  • xs:double
  • xs:decimal
  • xs:integer
  • xdt:untypedAtomic
  • A type that is derived from any of the previously listed types

If numeric-value has the xdt:untypedAtomic data type, it is converted to an xs:double value.

Returned value

If numeric-value is not the empty sequence, the returned value is the smallest integer that is greater than or equal to numeric-value. The data type of the returned value depends on the data type of numeric-value:
  • If numeric-value is xs:float, xs:double, xs:decimal, or xs:integer, the value that is returned has the same type as numeric-value.
  • If numeric-value has a data type that is derived from xs:float, xs:double, xs:decimal, or xs:integer, the value that is returned has the direct parent data type of numeric-value.

If numeric-value is the empty sequence, the returned value is the empty sequence.

Examples

Example with a positive argument: The following function returns the ceiling value of 0.5:
fn:ceiling(0.5)

The returned value is 1.

Example with a negative argument: The following function returns the ceiling value of (-1.2):
fn:ceiling(-1.2)

The returned value is -1.