It's worth mentioning here that the rules for output of numbers are not the same as the rules for input. When a number is converted to a string, the results are determined by the casting rules given in Chapter 11. To summarize these:
- An
xs:integer
value is output as an integer, for example,
42
or
-315
- An
xs:decimal
value with no fractional part is output as if it were an integer, with no decimal point. If it has a fractional part, it is output with at least one digit before and after the decimal point, and no other insignificant leading or trailing zeros. Examples of
xs:decimal
output are
42
,
-315
,
18.6
,
-0.0015
.
- An
xs:double
or
xs:float
value that's within the range 1e-6 to 1e+6 (one millionth to one million, positive or negative) is output in the same way as a decimal. Outside this range, exponential notation is used, with one significant digit before the decimal point. Examples of
xs:double
output are
42
,
-315
,
18.6
,
-0.0015
,
1.003e-12
,
-8.752943e13
.