Multiply or divide numerical values.
The MultiplicativeExpr
provides arithmetic operations for
multiplying and dividing numerical values. Each operand is
atomized so that
it is either a single atomic value or an empty sequence. If either of the
operands is atomized to an empty sequence, the result of the operation is also
an empty sequence. If the two operands are of different types, type promotion
is applied and the two operands are promoted to their least common type. The
operation is then performed and either an atomic value is returned or a dynamic
error such as division by zero issued.
The division operator is called div
, since the typical
division symbol /
is already used in path expressions. The result
of the div
operation has the least common type of its operands
unless both operands are integer values, in which case an atomic value of type
xs:double
is returned. The modulo operation (using the operator
mod
) returns the remainder of a division.
Compute the percentage of patients who have died:
count(input()//deceased) div count(input()/patient) * 100
Two multiplicative expressions are involved that are executed according
to the normal precedence rule, since neither of them is enclosed in
parentheses. The first operation divides the number of deceased patients by the
total number of patients. The result of this operation is of type
xs:double
, since the atomized values of both operands are integer
values. Consequently, the result of the following multiplication is also of
type xs:double
.
Select all patients who were born in the first year of a decade:
for $a in input()/patient where $a/born mod 10 = 0 return $a
The following construct(s) refer to this construct: