[Bug 2631] [XPath] Numeric Promotion

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

           Summary: [XPath] Numeric Promotion
           Product: XPath / XQuery / XSLT
           Version: Candidate Recommendation
          Platform: PC
               URL: http://lists.w3.org/Archives/Member/w3c-xsl-
                    query/2005Oct/0039.html
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XPath
        AssignedTo: chamberl@almaden.ibm.com
        ReportedBy: mike@saxonica.com
         QAContact: public-qt-comments@w3.org


This issue was raised on an internal email and is being copied here as a result
of action A-278-02. The issue reads:

In the Query test suite, test fn-distinct-values-mixed-args-012.xq is:

fn:distinct-values((xs:decimal('1.2'), xs:float('1.2')))

and the expected answer is "1.2".

This answer is valid if (xs:decimal('1.2') eq xs:float('1.2')).

But I'm having trouble deciding from the spec whether these two values are
equal. It hinges on the way promotion works.

If the decimal is promoted to a float, then the two values are equal.

If both values are promoted to doubles, then they are not equal. This is
because the float converts to the double 1.2000000476837158.

I don't think there is anything in the spec that tells us which way
promotion is supposed to work for a value comparison. It's interesting that
it makes such a dramatic difference to the result of a simple expression
like this. I suspect it's intended that the decimal should be promoted to a
float, making these test results correct (and Saxon wrong), but the spec
doesn't currently say so.


Michael Kay

Received on Tuesday, 3 January 2006 14:49:54 UTC