title: Decoding integer value
body: <p>I have this program that encodes integer values: </p>
  
  <pre><code>#include "stdafx.h"
  #define _SECURE_SCL_DEPRECATE 0
  #include &lt;iostream&gt;
  #include &lt;list&gt;
  #include &lt;vector&gt;
  #include &lt;algorithm&gt;
  
  using namespace std;
  
  template&lt;class T&gt;
  vector&lt;unsigned char&gt;  nToB(T );
  unsigned long ByteToint(vector&lt;unsigned char&gt; v)
  {
      unsigned long int a = 0;
      int s = v.size();
      for (int i = 0; i&lt;s ; i++)
      {
          a |= (v[s - 1 - i] &lt;&lt; (8 * (s - i - 1)));
      }
      return a;
  }
  
  static unsigned  long  int  Encode7Bits(unsigned long int);
  
  int main()
  {   
      cout &lt;&lt; Encode7Bits(420);
      getchar();
      return 0;
  }
  
  static unsigned  long  int  Encode7Bits( unsigned long int x)
  {
      vector&lt;unsigned char&gt; Result;
  
      do
      {
          unsigned long  int tmp = x &amp; 0x7f;
          x = x &gt;&gt; 7;
          if (x &gt; 0)
              tmp |= 0x80;        
          Result.push_back((unsigned char )tmp);
      } while (x &gt; 0);
  
      return ByteToint(Result);
  }
  </code></pre>
  
  <p>If the argument to this function is 420 it will return 932.</p>
  
  <p>My question is whether it is possible to do the reverse operation, a decoding function that given 932, returns 420. </p>