Multiply or divide numeric values.
A MultiplicativeExpr
either consists of a simple
UnaryExpr
or of two or more operands to UnaryExpr
separated by the operators that must be numeric values or can be converted to
numeric values. If at least one operator is not a numeric value or cannot be
converted, then the result is "NaN", a special value
to indicate that this is not a number. Otherwise the numeric values are treated
as double-length floating point numbers as specified in IEEE 754. This is
also true for the division operator, although it is called div
which is commonly used for the division of integer values (the typical division
sign /
is already used in path expressions). The modulo operation
(using the operator mod
) returns the remainder of a division.
In addition to "NaN" there are two other
special values as specified in IEEE 754, namely positive and negative
infinity. These are returned as "1.#INF" and
"-1.#INF" respectively. You get these values if you
perform queries such as 2 div 0
or 2 div -0
.
It corresponds to the expression MultiplicativeExpr
defined
in XPath, Section 3.5, Rule
6. This includes the XPath restriction that numbers cannot be used
in scientific notation.
Get the percentage of patients who died (divide the number of any
descendant deceased
nodes by the number of patient
nodes and multiply that value by 100):
count(//deceased) div count(/patient) * 100
Select all patients that were born in the first year of a decade:
/patient[born mod 10 = 0]
AdditiveExpr |