title: What does the precision of float, double or long double mean in C++?
body: <p>For example in this table they say 7 digits to float, and 15 digits to double:
  <a href="https://docs.microsoft.com/en-us/cpp/cpp/data-type-ranges" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/cpp/cpp/data-type-ranges</a></p>
  <p>But this statement returns 9:</p>
  <pre><code>std::cout &lt;&lt; std::numeric_limits&lt;float&gt;::max_digits10 &lt;&lt; '\n';
  </code></pre>
  <p>Add this returns 17:</p>
  <pre><code>std::cout &lt;&lt; std::numeric_limits&lt;double&gt;::max_digits10 &lt;&lt; '\n';
  </code></pre>
  <p>Maybe we should substract the + or the - sign, and the dot from the number of digits?
  Here they say that this precision is guaranteed digits remain after text -&gt; number -&gt; text conversion:
  <a href="https://en.cppreference.com/w/cpp/types/numeric_limits/max_digits10" rel="nofollow noreferrer">https://en.cppreference.com/w/cpp/types/numeric_limits/max_digits10</a></p>
  <p>But when i do this, the precision is always 7, in the case of double also:</p>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  int main() {
    double d_example = 0.123456789;
    std::string str_example = std::to_string(d_example);
    d_example = stod(str_example);
    std::cout &lt;&lt; str_example &lt;&lt; '\n';
    std::cout &lt;&lt; d_example &lt;&lt; '\n';
  }
  </code></pre>