<?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>29171</bug_id>
          
          <creation_ts>2015-10-02 13:33:28 +0000</creation_ts>
          <short_desc>[QT3TS] cbcl-numeric-idivide-008</short_desc>
          <delta_ts>2015-10-13 13:57:56 +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>XQuery 3 &amp; XPath 3 Test Suite</component>
          <version>Candidate Recommendation</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows NT</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></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="Debbie Lockett">debbie</reporter>
          <assigned_to name="Tim Mills">tim</assigned_to>
          <cc>mike</cc>
    
    <cc>tim</cc>
          
          <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>123447</commentid>
    <comment_count>0</comment_count>
    <who name="Debbie Lockett">debbie</who>
    <bug_when>2015-10-02 13:33:28 +0000</bug_when>
    <thetext>cbcl-numeric-idivide-008 (in test set op-numeric-integer-divide) tests:
xs:float(&apos;1e38&apos;) idiv xs:float(&apos;1e-37&apos;)

The test expects the overflow error FOAR0002, but it seems that FOCA0002 should also be allowed (raised when trying to convert infinity to an integer). Alternatively an implementation may return a large integer as the result.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>123450</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2015-10-02 14:45:27 +0000</bug_when>
    <thetext>A little more rationale on this:

The spec of idiv (via op:numeric-integer-divide) says it returns &quot;the largest integer such that....&quot;

so in principle an implementation that supports 75-digit integers ought to be able to deliver a successful result.

However, the specification also allows the implementation to choose a different algorithm that might have failure conditions if limits are exceeded, and it is not prescriptive about what error codes might arise in this case. Saxon is using the perfectly reasonable algorithm of doing an xs:float division and then rounding down to an integer. In this case the xs:float division produces INF and the rounding then fails.

For what it&apos;s worth, I&apos;ve experimented with a different algorithm and it produces 999999976930990075686379158893828419930518285429571090543203585326070980319, but I suspect other approaches might deliver a slightly different but equally valid result.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>123673</commentid>
    <comment_count>2</comment_count>
    <who name="Tim Mills">tim</who>
    <bug_when>2015-10-13 12:08:21 +0000</bug_when>
    <thetext>I&apos;ve added FOCA0002 and a large integer (1 x 10^75).

Please mark as CLOSED if you agree with the resolution.  Otherwise, REOPEN.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>123677</commentid>
    <comment_count>3</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2015-10-13 13:57:56 +0000</bug_when>
    <thetext>I have further modified the &quot;success&quot; result to

         &lt;any-of&gt;
            &lt;error code=&quot;FOAR0002&quot;/&gt;
            &lt;error code=&quot;FOCA0002&quot;/&gt;
            &lt;all-of&gt;
               &lt;assert-type&gt;xs:integer&lt;/assert-type&gt;
               &lt;assert&gt;matches(string($result), &apos;^[0-9]{75,76}$&apos;)&lt;/assert&gt;
            &lt;/all-of&gt;
         &lt;/any-of&gt;

since I think rounding errors are acceptable (given that we allow the implementation a wide choice of algorithms). For example if you promote both floats to doubles, do the division, and then round to an integer, you won&apos;t get exactly 10^75.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>