Name
round()
Returns the integer closest to the argument.
Syntax
[1.0] number?round(
number?
)
[2.0] numeric?round(
numeric?
)
Inputs
[1.0] A number. If the argument is not
a number, it is converted to a number as if it were passed to the
number()
function.
[2.0] In XSLT 2.0, the argument for
round()
must be a number
(xs:integer
, xs:float
, xs:
decimal
, or xs:double
, or a datatype derived from
them). If the argument is not a number, the XSLT processor raises
an error. For example, if the argument is an untyped value read in
from an XML document that doesn’t use a schema, it must be cast to
a numeric value before it is passed to round()
.
Output
The integer that is closest to the argument. If two numbers
are equally close to the argument (1
and 2
are equally close to 1.5
), the number closest to positive
infinity is returned. Various argument values are handled as
follows:
If the argument is positive infinity, then positive infinity is returned.
If the argument is negative infinity, then negative infinity is returned.
If the argument is positive zero, then positive zero is returned.
If the argument is negative zero, then negative zero is returned.
If the argument is between zero and
–0.5
, then negative zero is returned.If the argument is
NaN
(not a number), theround()
function returnsNaN
.
[2.0] In XSLT 2.0, the output value has
the same datatype as the input value. In other words, the function
round(xs:integer)
returns an
xs:integer
, while round(xs:float)
returns an xs:float
.
Defined in
[1.0] XPath ...
Get XSLT, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.