I have the following code:
Dim count As Integer = 0
While count < TotalBytes.Count
//Dim val As Short = (TotalBytes.ExtractShort(count) & RESULT_MASK) >> 2
Dim val As Short = ((TotalBytes(count) << 8 | TotalBytes(count + 1)) & RESULT_MASK) >> 2
result.Add(val)
count += 2
End While
Where TotalBytes is a ListofByte (and result is a ListofShort). The above code works and extracts the shorts correctly. If I use the commented out version (using ExtractShort), then it does not, the values returned are 1/2 the number of entries in TotalBytes (ie if TotalBytes is a list of 128 bytes, val is 64).
RESULTS_MASK just masks the top 4 bits. The values should be from 0 to 1023 (10 bits). As I say, my manual version works, ExtractShort does not.
Can anyone explain if I'm doing something wrong? I figure count is an offset into the ListofByte, but it doesn't seem to work.
Thanks,