[Bug 1277] clarification about semantics of +0.0 and -0.0 in http://www.w3.org/TR/xquery-operators/

http://www.w3.org/Bugs/Public/show_bug.cgi?id=1277





------- Additional Comments From pcotton@microsoft.com  2005-04-28 22:57 -------
The following are my attempts to answer your two questions.

1. min({xs:float(0.0), xs:float(-0.0)}) 

Section 6.3.1 op:numeric-equal states:

"For xs:float and xs:double values, positive zero and negative zero compare 
equal."

Note as well that this function is used to implement the operators eq, le, ge, 
and ne.

Section 15.4.4 fn:min states that the following code is used to implement the 
function (after certain other cases are covered):

  "Otherwise, the result of the function is the result of the expression:

   if (every $v in $c satisfies $c[1] le $v) 
   then $c[1] 
   else fn:min(fn:subsequence($c, 2)) "

Since fn:min()'s semantics depend on the "le" operator which is defined by the 
op:numeric-equal() function, this means that negative zero and positive zero 
(as floats or doubles) compare equal.

I personally agree that the F&O spec could be clarified by giving the answer 
for the example:
min({xs:float(0.0), xs:float(-0.0)})  
My personal guess is that we will have to permit either postive zero or 
negative zero to be returned but the WGs will have to decide this.

2. ordering/collation is of xs:float(0.0) and xs:float(-0.0)

To answer your sorting question you have to refer to XQuery/XSLT since the F&O 
spec itself does not define sorting.  But Section 3.8.3 Order By and Return 
Clauses in XQuery 1.0 does sorting using the "gt" operator so positive zero 
and negative zero would again be treated as the same.  

This section then goes on to define what happens for equal values:

"If neither V1 nor V2 is greater-than the other for any pair of orderspecs for 
tuples T1 and T2, then:

- If stable is specified, the original order of T1 and T2 is preserved in the 
tuple stream.

- If stable is not specified, the order of T1 and T2 in the tuple stream is 
implementation-dependent."

I think this clearly defines how ordering of negative and positive zero is 
handled in XQuery.  I assume it is as clear in XSLT 2.0.

/paulc

Received on Thursday, 28 April 2005 22:57:23 UTC