title: Why value of double seems to be changed after assignment?
body: <p>The result of the following program is a little bit strange to me on my machine.</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  int main(){
      double a = 20;
      double b = 0.020;
      double c = 1000.0;
  
      double d = b * c;
  
      if(a &lt; b * c)
          cout &lt;&lt; "a &lt; b * c" &lt;&lt; endl;
  
      if(a &lt; d)
          cout &lt;&lt; "a &lt; d" &lt;&lt; endl;
  
      return 0;
  }
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>$ ./test
  a &lt; b * c
  </code></pre>
  
  <p>I know double is not that accurate because of the precision. But I don't expect that value changed and give an inconsistent comparison result.</p>
  
  <p>If the <code>a &lt; b * c</code> get printed out, I do expect that <code>a &lt; d</code> should also get printed. But when I run this code on my i686 server and even on my cygwin. I can see <code>a &lt; b * c</code> but cannot see <code>a &lt; d</code>.</p>
  
  <p>This issue has been confirmed to be platform dependent. Is this caused by the different instruction and implementation of double assignment?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>The generated assembly:</p>
  
  <pre><code>main:
  .LFB1482:
      pushl   %ebp
  .LCFI0:
      movl    %esp, %ebp
  .LCFI1:
      subl    $56, %esp
  .LCFI2:
      andl    $-16, %esp
      movl    $0, %eax
      subl    %eax, %esp
      movl    $0, -8(%ebp)
      movl    $1077149696, -4(%ebp)
      movl    $1202590843, -16(%ebp)
      movl    $1066695393, -12(%ebp)
      movl    $0, -24(%ebp)
      movl    $1083129856, -20(%ebp)
      fldl    -16(%ebp)
      fmull   -24(%ebp)
      fstpl   -32(%ebp)
      fldl    -16(%ebp)
      fmull   -24(%ebp)
      fldl    -8(%ebp)
      fxch    %st(1)
      fucompp
      fnstsw  %ax
      sahf
      ja  .L3
      jmp .L2
  
      //.L3 will call stdout
  </code></pre>