3.5 Numbers
Numbers
A number represents a floating-point number. A number can have any
double-precision 64-bit format IEEE 754 value IEEE754.
These include a special "Not-a-Number" (NaN) value,
positive and negative infinity, and positive and negative zero. See
Section 4.2.3 of JLS for a summary of the key
rules of the IEEE 754 standard.
The numeric operators convert their operands to numbers as if by
calling the number function.
The + operator performs addition.
The - operator performs subtraction.
NOTE:
Since XML allows - in names, the -
operator typically needs to be preceded by whitespace. For example,
foo-bar evaluates to a node-set containing the child
elements named foo-bar; foo - bar evaluates
to the difference of the result of converting the
[string-value]
of the first
foo child element to a number and the result of
converting the
[string-value]
of the first bar child to a number.
The div operator performs floating-point division
according to IEEE 754.
The mod operator returns the remainder from a
truncating division. For example,
-
5 mod 2 returns 1
-
5 mod -2 returns 1
-
-5 mod 2 returns -1
-
-5 mod -2 returns -1
NOTE:
This is the same as the % operator in Java and
ECMAScript.
NOTE:
This is not the same as the IEEE 754 remainder operation, which
returns the remainder from a rounding division.
Numeric Expressions
|