<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>2631</bug_id>
          
          <creation_ts>2006-01-03 14:49:39 +0000</creation_ts>
          <short_desc>[XPath] Numeric Promotion</short_desc>
          <delta_ts>2006-02-14 01:22:33 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>XPath / XQuery / XSLT</product>
          <component>XPath 2.0</component>
          <version>Candidate Recommendation</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows XP</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc>http://lists.w3.org/Archives/Member/w3c-xsl-query/2005Oct/0039.html</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Michael Kay">mike</reporter>
          <assigned_to name="Don Chamberlin">chamberl</assigned_to>
          
          
          <qa_contact name="Mailing list for public feedback on specs from XSL and XML Query WGs">public-qt-comments</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>7577</commentid>
    <comment_count>0</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2006-01-03 14:49:40 +0000</bug_when>
    <thetext>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(&apos;1.2&apos;), xs:float(&apos;1.2&apos;)))

and the expected answer is &quot;1.2&quot;.

This answer is valid if (xs:decimal(&apos;1.2&apos;) eq xs:float(&apos;1.2&apos;)).

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


Michael Kay</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>7579</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2006-01-03 15:15:42 +0000</bug_when>
    <thetext>Proposal to resolve issue 2631: under action A-278-02 I was asked to propose
wording to resolve this issue editorially.

The first difficulty is a lack of uniformity in the operator mapping table:
numeric operations are handled using a generic type &quot;numeric&quot; than embraces
decimal, integer, float, and double, but there is no corresponding generic type
for anyURI and string. I think it would be rather disruptive to try and fix that
now, so the solution below is a little bit asymmetric.

Proposal
========

1. In 3.5.1 Value Comparisons, add a step 5 as follows:

   5. If both the operands are numeric, or if one is of type xs:string and the
other of type xs:anyURI, apply type promotion to one of the operands as
described in B.1 Type Promotion, so that the two operands have the same
primitive type.

2. In Appendix B.2, there is explanatory text for numeric promotion applied to
arithmetic operators, but no similar explanation for comparison operators. 

2a. Add a new fourth paragraph to B.2:

   Before looking up an entry in the table below, type promotion is applied
   to the operands as described in B.1 Type Promotion. 

2b. To the paragraph starting &quot;A numeric operator may be validly applied to an
operand of type...&quot;, add the following:

   &quot;Where the entry for an operator with numeric operands gives a result type
other than numeric (for example idiv, which has a result type of xs:integer, or
eq, which has a result type of xs:boolean), then the result is a value of that
type, regardless of the types of the operands. For example, the result of
comparing an integer to a decimal using the eq operator is a boolean&quot;. 

Michael Kay</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>7582</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2006-01-03 17:11:52 +0000</bug_when>
    <thetext>Please note that

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

is also relevant.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>8254</commentid>
    <comment_count>3</comment_count>
    <who name="Don Chamberlin">chamberl</who>
    <bug_when>2006-02-14 01:22:22 +0000</bug_when>
    <thetext>Mike,
On 01 Feb. 2006, the Query and XSLT working groups agreed with your suggestion 
to make editorial changes clarifying the rules for numeric promotion in value 
comparisons. Since you were present at the discussion, I am marking this 
Bugzilla entry as closed.
Regards,
Don Chamberlin</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>