<?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>3346</bug_id>
          
          <creation_ts>2006-06-18 20:14:08 +0000</creation_ts>
          <short_desc>K-NumericAdd-5, K-NumericAdd-6: floating point assumption wrong</short_desc>
          <delta_ts>2006-06-27 15:48:06 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>XML Query Test Suite</product>
          <component>XML Query Test Suite</component>
          <version>0.9.4</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows XP</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="Michael Kay">mike</reporter>
          <assigned_to name="Frans Englich">frans.englich</assigned_to>
          <cc>simeon</cc>
          
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>10087</commentid>
    <comment_count>0</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2006-06-18 20:14:08 +0000</bug_when>
    <thetext>The test is:

xs:double(1.1) + xs:double(2.2) eq 3.3

I believe the correct answer is false().

The internal representation of double 1.1 is x3ff199999999999a

The exact decimal value of this is 
1.100000000000000088817841970012523233890533447265625

This is the correct representation because the value is closer to 1.1 than the next lower value in the value space of double, whose exact decimal value is
1.0999999999999998667732370449812151491641998291015625

The internal representation of double 2.2 is x400199999999999a

The exact decimal value of this is 
2.20000000000000017763568394002504646778106689453125

This is the correct representation because the value is closer to 2.2 than the next lower value in the value space of double, whose exact decimal value is
2.199999999999999733546474089962430298328399658203125

The internal representation of double 3.3 is x400a666666666666

The exact decimal value of this is 
3.29999999999999982236431605997495353221893310546875

This is the correct representation because the value is closer to 3.3 than the next higher value in the value space of double, whose exact decimal value is
3.300000000000000266453525910037569701671600341796875

The result of adding the doubles 1.1 and 2.2 is the double whose internal representation is x400a666666666667, whose exact decimal value is
3.300000000000000266453525910037569701671600341796875 

This is not the same as the internal representation of the double 3.3.

So 1.1 + 2.2 != 3.3. 

QED.

I believe the same reasoning applies to K-NumericAdd-6, which uses float arithmetic, though I have not done the detailed analysis for this case.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>10288</commentid>
    <comment_count>1</comment_count>
    <who name="Frans Englich">frans.englich</who>
    <bug_when>2006-06-27 15:25:21 +0000</bug_when>
    <thetext>*** Bug 3382 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>10289</commentid>
    <comment_count>2</comment_count>
    <who name="Frans Englich">frans.englich</who>
    <bug_when>2006-06-27 15:47:34 +0000</bug_when>
    <thetext>K-NumericAdd-5 was changed to:
xs:double(1.1) + xs:double(2.2) ne 3.3

K-NumericAdd-6 was changed to:
xs:float(1.1) + xs:float(2.2) ne 3.3

Nice analysis. Might very well come in handy in other situations.

Since this erport was fixed as suggested, I will change status to CLOSED.



Frans</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>