Author Topic: Anyone know how ExtractShort() works?  (Read 92 times)


  • Full Member
  • ***
  • Posts: 215
    • View Profile
Anyone know how ExtractShort() works?
« on: January 31, 2017, 04:29:12 pm »
I have the following code:

Code: [Select]
    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
            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.


Share on Facebook Share on Twitter


  • Global Moderator
  • Newbie
  • *****
  • Posts: 27
    • View Profile
Re: Anyone know how ExtractShort() works?
« Reply #1 on: February 01, 2017, 05:04:27 pm »

We have confirmed that the ExtractShort() method does not return the correct result. We will have this problem fixed in the next release. Thank you for pointing this out!