fn:round function
The fn:round function returns the integer that is closest to the specified numeric value.
Syntax
- numeric-value
- An atomic value or an empty sequence.If numeric-value is an atomic value, it has one of the following types:
- xs:double
- xs:decimal
- xs:integer
- A type that is derived from any of the previously listed types
Returned value
If numeric-value is
not the empty sequence, the returned value is the integer that is
closest to numeric-value. The data type of the returned value
depends on the data type of numeric-value:
- If numeric-value is 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: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 rounded value of 0.5:
fn:round(0.5)
The returned value is 1.
Example with a negative argument: The
following function returns the rounded value of (-1.5):
fn:round(-1.5)
The returned value is -1.