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

Nick_W

  • Full Member
  • ***
  • Posts: 214
    • 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
            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,

Share on Facebook Share on Twitter Share on Google+


mc-Josh

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

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!

Josh