<?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>6316</bug_id>
          
          <creation_ts>2008-12-16 16:56:32 +0000</creation_ts>
          <short_desc>[FO] An error should be raised if second argument to op:numeric-integer-divide is INF or -INF</short_desc>
          <delta_ts>2009-01-28 20:47:23 +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>Functions and Operators 1.0</component>
          <version>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://www.w3.org/TR/xpath-functions/#func-numeric-integer-divide</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P4</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Henry Zongaro">zongaro</reporter>
          <assigned_to name="Michael Kay">mike</assigned_to>
          <cc>andrew.eisenberg</cc>
    
    <cc>jim.melton</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>22769</commentid>
    <comment_count>0</comment_count>
    <who name="Henry Zongaro">zongaro</who>
    <bug_when>2008-12-16 16:56:32 +0000</bug_when>
    <thetext>The third paragraph of section 6.2.6 of F&amp;O states, &quot;If the divisor is (positive or negative) zero, then an error is raised [err:FOAR0001]. If either operand is NaN or if $arg1 is INF or -INF then an error is raised [err:FOAR0002].&quot;

I think we need to prohibit the second operand from being positive or negative infinity as well.  If $a is finite, but $b is not finite, there is no value of type xs:integer that could be delivered as the result of ($a idiv $b) so that the following relation is true.

   (($a idiv $b) * $b) + ($a mod $b) = $a

I believe the second sentence should read, &quot;If either operand is NaN, positive infinity or negative infinity, then an error is raised [err:FOAR0002].&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>22929</commentid>
    <comment_count>1</comment_count>
    <who name="Andrew Eisenberg">andrew.eisenberg</who>
    <bug_when>2009-01-05 21:37:20 +0000</bug_when>
    <thetext>I would suggest a different fix fro this problem.

In our Recommendation we said:

&quot;If the dividend, $arg1, is not evenly divided by the divisor, $arg2, then the quotient is the xs:integer value obtained, ignoring (truncating) any remainder that results from the division (that is, no rounding is performed). Thus, the semantics &quot; $a idiv $b &quot; are equivalent to &quot; ($a div $b) cast as xs:integer &quot; except for error situations.&quot;

I believe that this leads us to having xs:float(&quot;4&quot;) idiv xs:float(&quot;INF&quot;) return 0.

Our editors draft of F&amp;O 1.1/2.1, reflecting our resolution of Bug #6212, says:

&quot;If the divisor is (positive or negative) zero, then an error is raised [err:FOAR0001]. If either operand is NaN or if $arg1 is INF or -INF then an error is raised [err:FOAR0002].

Otherwise, subject to limits of precision and overflow/underflow conditions, the result is the largest (furthest from zero) xs:integer value $N such that fn:abs($N * $arg2) le fn:abs($arg1) and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).&quot;

There is no value of $N, where $arg1 is not NaN, INF, or -INF and $arg2 is INF, that satisfies the expression in the second paragraph (remembering that 0 * INF is NaN and NaN le any value is false).

I believe that we should change the first paragraph to say:

&quot;If the divisor is (positive or negative) zero, then an error is raised [err:FOAR0001]. If either operand is NaN or if $arg1 is INF or -INF then an error is raised [err:FOAR0002]. [Insert: If $arg2 is INF or -INF, then the result is 0.]&quot;


</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>22953</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2009-01-06 16:38:39 +0000</bug_when>
    <thetext>Decided that the result of A idiv INF should be zero. This technically needs no changes to the text, except possibly for clarification.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>23284</commentid>
    <comment_count>3</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2009-01-28 20:34:35 +0000</bug_when>
    <thetext>Erratum E33 has been drafted to clarify that when the second argument is INF or -INF, the idiv operator returns zero.

I am marking this bug as fixed, if you agree please mark it closed.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>23286</commentid>
    <comment_count>4</comment_count>
    <who name="Henry Zongaro">zongaro</who>
    <bug_when>2009-01-28 20:47:23 +0000</bug_when>
    <thetext>I agree with the resolution.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>