title: c++ (double)0.700 * int(1000) => 699 (Not the double precision issue)
body: <p>using g++ (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3</p>
  
  <p>I have tried different typecasting of <code>scaledvalue2</code> but not until I stored the multiplication in a <code>double</code> variable and then to an <code>int</code> could I get desired result.. but I can't explain why ???</p>
  
  <p>I know double precission(0.6999999999999999555910790149937383830547332763671875) is an issue but I don't understand why one way is OK and the other is not ??</p>
  
  <p>I would expect both to fail if precision is a problem.</p>
  
  <p>I DON'T NEED solution to fix it.. but just a WHY ??
  (the problem IS fixed)</p>
  
  <pre><code>void main()
  {
      double value = 0.7;
      int scaleFactor = 1000;
  
      double doubleScaled = (double)scaleFactor * value; 
      int scaledvalue1 = doubleScaled; // = 700
  
      int scaledvalue2 = (double)((double)(scaleFactor) * value);  // = 699 ??
  
      int scaledvalue3 = (double)(1000.0 * 0.7);  // = 700 
  
      std::ostringstream oss;
      oss &lt;&lt; scaledvalue2;
      printf("convert FloatValue[%f] multi with %i to get %f = %i or %i or %i[%s]\r\n",
        value,scaleFactor,doubleScaled,scaledvalue1,scaledvalue2,scaledvalue3,oss.str().c_str());
  
  }
  </code></pre>
  
  <p>or in short:</p>
  
  <pre><code>value = 0.6999999999999999555910790149937383830547332763671875;
  int scaledvalue_a = (double)(1000 * value);  // =  699??
  int scaledvalue_b = (double)(1000 * 0.6999999999999999555910790149937383830547332763671875);  // =  700
  // scaledvalue_a = 699
  // scaledvalue_b = 700
  </code></pre>
  
  <p>I can't figure out what is going wrong here.</p>
  
  <p>Output :</p>
  
  <pre><code>convert FloatValue[0.700000] multi with 1000 to get 700.000000 = 700 or 699 or 700[699]
  </code></pre>
  
  <blockquote>
    <p>vendor_id       : GenuineIntel</p>
    
    <p>cpu family      : 6</p>
    
    <p>model           : 54</p>
    
    <p>model name      : Intel(R) Atom(TM) CPU N2600   @ 1.60GHz</p>
  </blockquote>