title: Losing precision with floating point numbers (double) in c++
body: <p>I'm trying to assign a big <code>double</code> value to a variable and print it on the console. The number I supply in is different than what is displayed as output. Is it possible to get the <code>double</code> value correctly assigned and output without the loss of precision? Here is the C++ code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;limits&gt;
  
  int main( int argc, char *argv[] ) {
  
      // turn off scientific notation on floating point numbers
      std::cout &lt;&lt; std::fixed &lt;&lt; std::setprecision( 3 );
  
      // maximum double value on my machine
      std::cout &lt;&lt; std::numeric_limits&lt;double&gt;::max() &lt;&lt; std::endl;
  
      // string representation of the double value I want to get
      std::cout &lt;&lt; "123456789123456789123456789123456789.01" &lt;&lt; std::endl;
  
      // value I supplied        
      double d = 123456789123456789123456789123456789.01;
  
      // it's printing 123456789123456784102659645885120512.000 instead of 123456789123456789123456789123456789.01
      std::cout &lt;&lt; d &lt;&lt; std::endl;
  
      return EXIT_SUCCESS;
  }
  </code></pre>
  
  <p>Could you, please, help me to understand the problem.</p>