stoneharry

Untitled

Sep 23rd, 2013
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.86 KB | None | 0 0
  1.        internal int ReadInt32(int numBits)
  2.         {
  3.             if (numBits <= 0)
  4.                 return 0;
  5.             int ret = 0;
  6.             while (true)
  7.             {
  8.                 if (ReadPos >= _numBits)
  9.                 {
  10.                     return ret;
  11.                 }
  12.  
  13.                 int pos7 = (ReadPos & 7);
  14.                 int bitsLeftInByte = 8 - pos7;
  15.  
  16.                 int subNum = bitsLeftInByte;
  17.                 if (bitsLeftInByte >= numBits)
  18.                     subNum = numBits;
  19.  
  20.                 var lShift = (byte) (1 << subNum);
  21.  
  22.                 int v10 = _buffer[ReadPos >> 3] >> (ReadPos & 7);
  23.                 numBits -= subNum;
  24.  
  25.                 ret |= ((lShift - 1) & v10) << numBits;
  26.                 _readPos = ReadPos + subNum;
  27.  
  28.                 if (numBits == 0)
  29.                     return ret;
  30.             }
  31.         }
Advertisement
Add Comment
Please, Sign In to add comment