Author Topic: ListofShort.Min() Not working  (Read 408 times)

Nick_W

  • Full Member
  • ***
  • Posts: 215
    • View Profile
ListofShort.Min() Not working
« on: January 31, 2017, 03:37:54 pm »
Just FYI,

I found that ListofShort.Min() returns the same value as ListofShort.Max()

I have a ListofShort called Values, and was publishing Values.Max - Values.Min to see what the swing was. I kept getting 0 as the value.

I wrote a workaround that calculates Values.Min, and now all is well (I'm assuming ListofShort.Max() works, it seems to return believable values).

Just add to the bug list.

Oh and "For a As Integer To b as Step 2" doesn't work either you always just get 1 step. I don't know if other step values work or not, but 2 doesn't.
It's the Step value that is the problem, without this (ie leave Step off), the default (Step 1) works (as long as you want Step 1).

Share on Facebook Share on Twitter


mc-Josh

  • Global Moderator
  • Newbie
  • *****
  • Posts: 27
    • View Profile
Re: ListofShort.Min() Not working
« Reply #1 on: February 01, 2017, 03:55:28 pm »
Nick,

We have confirmed that the .Min() method returns the max value for all data types, not just Short. We will have this problem fixed in the next release. Thank you for pointing this out!

We have also tried to replicate the for loop step problem but it seems to be working fine for us. If I run the following code:

Code: [Select]
Class testCase   
    Shared Event Boot()       
        Dim value As Integer = 0       
        For a As Integer = 0 To 6 Step 2
            value = a
        Next       
    End Event   
End Class

I get the expected results of stepping by 2 per loop iteration. Can you elaborate on what you are seeing?

Josh

Nick_W

  • Full Member
  • ***
  • Posts: 215
    • View Profile
Re: ListofShort.Min() Not working
« Reply #2 on: February 02, 2017, 06:52:08 am »
You're right, the For loop now works. Must have been doing something else wrong.

This is the actual code I was running:

Code: [Select]
        For count As Integer = 0 To TotalBytes.Count- 1 Step 2
            //Dim val As Short = (TotalBytes.ExtractShort(count, Endianness.Big) & RESULT_MASK) >> 2 //optional endian
            Dim val As Short = ((TotalBytes(count) << 8 | TotalBytes(count + 1)) & RESULT_MASK) >> 2
            result.Add(val)
        Next

Which now works correctly, before it was returning a list of 1 entry.

Never mind...