Read XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition Online
Authors: Michael Kay
The function has been generalized to work with all numeric types.
Signature
Argument | Type | Meaning |
value | Numeric? | The supplied number. If an empty sequence is supplied, an empty sequence is returned. |
Result | Numeric? | The result of rounding down the supplied number to the integer below. The result has the same type as the supplied value . |
Effect
If the number is an
xs:integer
, or is equal to an
xs:integer
, then it is returned unchanged.
Otherwise, it is rounded down to the next lowest whole number. If the supplied value is an
xs:decimal
, the result will be an
xs:decimal
, if it is an
xs:double
, the result will be an
xs:double
, and if it is an
xs:float
, the result will be an
xs:float
. In the case of negative numbers, the rounding is away from zero.
The
xs:double
and
xs:float
types in XPath support special values such as infinity, negative zero and NaN (not-a-number), which are described on page 199 in Chapter 5.
If the argument is NaN (not-a-number), the result will be NaN. Similarly, when the argument is positive or negative infinity, the function will return the value of the argument unchanged.
Examples
Expression | Result |
floor(1.0) | xs:decimal 1.0, displayed as 1 |
floor(1.6e0) | xs:double 1.0e0, displayed as 1 |
floor(17 div 3) | xs:decimal 5.0, displayed as 5 |
floor(-3.0) | xs:decimal β3.0, displayed as -3 |
floor(-8.2e0) | xs:double β9.0e0, displayed as -9 |
floor(number(βNaNβ)) | xs:double NaN |
Usage
Like
round()
and
ceiling()
, this function is useful when calculating sizes of HTML tables.
Two alternatives you may want to consider are: