title: Logic error in writing the number twice in a row (C++)
body: <p>I have been trying to implement something in C++ but apparently, there's a syntax error.</p>
  
  <ol>
  <li><p>The following code yields "1 3100" when 31 is entered as input : </p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;cmath&gt;
  using namespace std;
  int main()
  {
      long long n; cin&gt;&gt;n;
      long long j = floor((log10(n)));
      long long nn = (n*((long long)pow(10,j+1)))+n;
      cout&lt;&lt;j&lt;&lt;" "&lt;&lt;nn;
  }
  </code></pre></li>
  <li><p>The following code yields "1 3130" for the same input, i.e, 31 :</p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;cmath&gt;
  using namespace std;
  int main()
  {
      long long n; cin&gt;&gt;n;
      long long j = floor((log10(n)));
      long long nn = (n*(pow(10,j+1)))+n;
      cout&lt;&lt;j&lt;&lt;" "&lt;&lt;nn;
  }
  </code></pre></li>
  </ol>
  
  <p>And I wished to produced "1 3131" for the input 31. Basically, I am trying to write the number twice in a row: the same thing that you get when you parse the number into string and add the same string twice (like, n=11, parse into s = "11" and then yield s+s).<br>
  So I want to multiply the input by a suitable power of ten to get enough "trailing zeros" and then add the input again.</p>
  
  <p>Where am I going wrong? Also, why is there a difference between the two codes above? (Please explain why the first code gives that as an output and the second code that as an output and also help me with a newer code to get the desired output).</p>