title: C++ double to long long
body: <p>If i write code in c++: </p>
  
  <pre><code>long long d = 999999998.9999999994;
  cout&lt;&lt;d;
  </code></pre>
  
  <p>I get output: <code>999999999</code> (rounding up)</p>
  
  <p>But output of this code:</p>
  
  <pre><code>long long d = 999999998.9999994994;
  cout&lt;&lt;d;
  </code></pre>
  
  <p>is <code>999999998</code> (rounding down)</p>
  
  <p>Is it something to do with precision. Is there any way i can change precision. <code>floor()</code> function also gives the same output.</p>
  
  <p>I also noticed that if i assign value <code>8.9999994994</code> or <code>8.9999999994</code> to <code>d</code>(above variable). Output is <code>8</code>.</p>