Menu

Bug in "GetIntAt" in snap7.net.cs - bad negative value conversion

2016-01-14
2016-01-21
  • Łukasz Stefanowicz

    Hi,
    casting to int in GetIntAt function causes negative values to be read as "bigger positive".
    Fixed part of code:

    public static int GetIntAt(byte[] Buffer, int Pos)
    {
         // FIXED: cast to int spoils negative values
        return (short)((Buffer[Pos] << 8) | Buffer[Pos + 1]); 
    }
    

    Thanks,
    Łukasz Stefanowicz

     
  • Davide Nardella

    Davide Nardella - 2016-01-21

    Thanks for the fix ;)

     

Log in to post a comment.

MongoDB Logo MongoDB