# [xquery-talk] BumbleBee XQuery Test Harness

Jeni Tennison jeni at jenitennison.com
Thu Oct 16 12:53:58 PDT 2003

```Jason Hunter wrote:
> Michael Kay wrote:
>> We've had great difficulty getting everyone to agree on the rules
>> for converting doubles to strings, partly because it's hard to get
>> people to focus their attention on something so trivial. In Saxon,
>> I have stuck to the XPath 1.0 rules until now, partly because I
>> didn't feel that the 2.0 rules were stable yet and partly because
>> they are unusable (e.g. in XSLT, chapters numbered 2.0e0). The WGs
>> have now agreed the rules and they will appear in the next versions
>> of the specs. In rough terms, the output will follow the XPath 1.0
>> rules for numbers in the range 1e-6 to 1e+6, but will use
>> exponential notation outside that range.
>
> Thanks for the clarification!  Here's the pertinent section from
> http://www.w3.org/TR/xpath:
>
> "otherwise, the number is represented in decimal form as a Number
> including a decimal point with at least one digit before the decimal
> point and at least one digit after the decimal point, preceded by a
> minus sign (-) if the number is negative; there must be no leading zeros
> before the decimal point apart possibly from the one required digit
> immediately before the decimal point; beyond the one required digit
> after the decimal point there must be as many, but only as many, more
> digits as are needed to uniquely distinguish the number from all other
> IEEE 754 numeric values."

- NaN is converted to the string NaN

- positive zero is converted to the string 0

- negative zero is converted to the string 0

- positive infinity is converted to the string Infinity
(I guess this will be INF in XPath 2.0)

- negative infinity is converted to the string -Infinity
(I guess this will be -INF in XPath 2.0)

- if the number is an integer, the number is represented in decimal
form as a Number with no decimal point and no leading zeros,
preceded by a minus sign (-) if the number is negative

The last is particularly important: if the value is an integer (i.e.
it has no significant decimal digits), then it's formatted as an
integer, without a trailing ".0".

The exact URL is:

http://www.w3.org/TR/xpath#function-string

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/

```