Got an iPhone or iPad? We have a brand new Pastebin App for both devices, and it's totally free! Click here to download the new Pastebin App for iOS.
Guest

Untitled

By: a guest on Feb 8th, 2010  |  syntax: C#  |  size: 0.75 KB  |  hits: 71  |  expires: Never
download  |  raw  |  embed  |  report abuse
Copied
  1.         public int decodeVL64L64(string data)
  2.         {
  3.             return decodeVL64L64(data.ToCharArray());
  4.         }
  5.                
  6.                 public int decodeVL64L64(char[] raw)
  7.         {
  8.             int position = 0;
  9.             int VL64 = 0;
  10.             bool negative = (raw[position] & 4) == 4;
  11.             int totalBytes = raw[position] >> 3 & 7;
  12.             VL64 = raw[position] & 3;
  13.             position++;
  14.             int shiftAmount = 2;
  15.                        
  16.             for (int j = 1; j < totalBytes; j++)
  17.             {
  18.                 VL64 |= (raw[position] & 0x3f) << shiftAmount;
  19.                 shiftAmount = 2 + 6 * j;
  20.                 position++;
  21.             }
  22.  
  23.             if (negative == true)
  24.                 VL64 *= -1;
  25.             return VL64;
  26.         }