title: How to count decimal digits of an integer?
body: <p>I wrote a program to determine the number of digits in a number</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cmath&gt;
  using namespace std;
  
  int main()
  {
      long long num1 = 1999999999999999;
      long long num2 = 9999999999999999;
      int number_of_digit_1 = log10(num1) + 1;
      int number_of_digit_2 = log10(num2) + 1;
      cout &lt;&lt; number_of_digit_1 &lt;&lt; endl;
      cout &lt;&lt; number_of_digit_2 &lt;&lt; endl;
  }
  </code></pre>
  
  <p>The output is this</p>
  
  <pre><code>16 
  17
  </code></pre>
  
  <p>Eventhough it shoudld print the same number (16). Why does this happen?</p>