
Untitled
By: a guest on Feb 8th, 2010 | syntax:
C# | size: 0.75 KB | hits: 71 | expires: Never
public int decodeVL64L64(string data)
{
return decodeVL64L64(data.ToCharArray());
}
public int decodeVL64L64(char[] raw)
{
int position = 0;
int VL64 = 0;
bool negative = (raw[position] & 4) == 4;
int totalBytes = raw[position] >> 3 & 7;
VL64 = raw[position] & 3;
position++;
int shiftAmount = 2;
for (int j = 1; j < totalBytes; j++)
{
VL64 |= (raw[position] & 0x3f) << shiftAmount;
shiftAmount = 2 + 6 * j;
position++;
}
if (negative == true)
VL64 *= -1;
return VL64;
}