<?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>15233</bug_id>
          
          <creation_ts>2011-12-16 15:41:33 +0000</creation_ts>
          <short_desc>[QT3TS] math-exp10-004, math-tan-006, math-tan-007</short_desc>
          <delta_ts>2013-03-20 10:48:44 +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>Member-only Editors Drafts</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows NT</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>INVALID</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="Tim Mills">tim</reporter>
          <assigned_to name="Jim Melton">jim.melton</assigned_to>
          <cc>andrew.eisenberg</cc>
    
    <cc>jim.melton</cc>
    
    <cc>mike</cc>
    
    <cc>oneil</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>61664</commentid>
    <comment_count>0</comment_count>
    <who name="Tim Mills">tim</who>
    <bug_when>2011-12-16 15:41:33 +0000</bug_when>
    <thetext>Our implementation returns the following results which differ from the expected results by a single bit in their representation.

math-exp10-004: 3.162277660168379
math-tan-006: 1.6331778728383844E16
math-tan-007: -1.6331778728383844E16</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61669</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2011-12-16 15:50:36 +0000</bug_when>
    <thetext>Yes, we observed a similar effect with Saxon - the .NET library methods give slightly different results to the Java library methods. I haven&apos;t attempted to work out whether both are conformant to the IEEE spec, which is what we reference.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>67839</commentid>
    <comment_count>2</comment_count>
    <who name="O&apos;Neil Delpratt">oneil</who>
    <bug_when>2012-05-18 09:48:04 +0000</bug_when>
    <thetext>We need discussion on whether to accept these results.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>68059</commentid>
    <comment_count>3</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2012-05-23 15:10:27 +0000</bug_when>
    <thetext>The first test is exp10(0.5), which means the same as sqrt(10), which Wolfram Alpha gives as

3.162277660168379331998893544432718533719555139325216826857504852792594438639238221344248108379300295187...

This lies between the two candidate results of 3.162277660168379 and 3.1622776601683795.

Note that for math-tan-006 and math-tan-007 the mathematical answer is infinity (and this is the value that Wolfram Alpha gives). So the test is close to a singularity in the function, which means that expecting high precision in the answer is unreasonable. If we accept pi = 3.141592653589793, we have two possible value for pi/2 depending on the rounding mode: 1.5707963267948966 and 1.5707963267948967. According to WA, tan(1.5707963267948966) is 5.1998506188720270660194741661226868475811544986... × 10^16, while tan (1.5707963267948966) is -1.238103706714353220651983005784184862681851980... × 10^16. So if we allow pi/2 to be rounded either way, the range of permissible values here is vast.

In the spec we say &quot;the preferred quantum is implementation-defined&quot;. I think this may be a misunderstanding of what the &apos;quantum&apos; is. I suspect that by specifying that the operations are done in xs:double floating point, we have effectively defined the quantum.

More pertinently to this bug, th IEEE spec says (in 4.3) there is a choice of &quot;rounding direction&quot;, with options such as towards zero, towards positive, towards negative. We haven&apos;t said anything about this. We should probably say &quot;The choice of rounding direction, and any mechanisms for influencing the choice of rounding direction, are implementation-defined.&quot; 

This means that the two results for sqrt(10) given above differ only in the choice of rounding direction, and both are therefore acceptable.

Recommendation:

(a) for math-tan-006 and math-tan-007, change the tests to avoid evaluating the function so close to a singularity, where there is a high sensitivity to legitimate implementation differences.

(b) for math-exp10-004, accept both results

(c) in the spec, change what we say about precision of results, to include the statement about rounding direction given above.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>68283</commentid>
    <comment_count>4</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2012-05-29 22:38:23 +0000</bug_when>
    <thetext>The recommendations in comment 3 were accepted by the WG and have been implemented.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>68387</commentid>
    <comment_count>5</comment_count>
    <who name="Tim Mills">tim</who>
    <bug_when>2012-05-31 10:11:31 +0000</bug_when>
    <thetext>For math-tan-006:

math:tan(math:pi() div 4)

I get the result 

0.9999999999999999

For math-tan-007:

math:tan(math:pi() div 4)

I get the result 

-0.9999999999999999</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>68390</commentid>
    <comment_count>6</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2012-05-31 10:36:08 +0000</bug_when>
    <thetext>Those look identical to the results expected - I&apos;m not sure what the problem is.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>68400</commentid>
    <comment_count>7</comment_count>
    <who name="Tim Mills">tim</who>
    <bug_when>2012-05-31 12:05:27 +0000</bug_when>
    <thetext>The problem turned out to be an error in casting from decimal to double in the test harness.  Note that the expected result is expressed as a decimal, whereas the actual result is a double.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>84719</commentid>
    <comment_count>8</comment_count>
    <who name="O&apos;Neil Delpratt">oneil</who>
    <bug_when>2013-03-20 10:48:44 +0000</bug_when>
    <thetext>*** Bug 18478 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>