1

Closed

BigEndianConvert class bug

description

Hi,
Thanks for this great toolkit
I think that I found a bug in the BigEndianConvert class.
The method "ToInt32(byte[] value, int startIndex)" doesn't work fine.
 
I think this is the correct version:
 
public static int ToInt32(byte[] value, int startIndex)
    {
        if (value == null)
        {
            throw new ArgumentNullException("value");
        }
        if (startIndex < 0 || startIndex > (value.Length - 4))
        {
            throw new ArgumentOutOfRangeException("startIndex", "Argument is out of range");
        }
        return value[startIndex] << 24 | value[startIndex + 1] << 16 |
            value[startIndex + 2] << 8 | value[startIndex + 3];
    }
 
I modified the last code row
"value[startIndex] << 8 | value[startIndex + 1];"
in
"value[startIndex + 2] << 8 | value[startIndex + 3];"
 
bye
Closed Apr 29, 2009 at 4:41 AM by Fortuitus

comments

wrote Apr 29, 2009 at 4:39 AM

Great find!  Thank-you.

wrote Apr 29, 2009 at 4:41 AM

Resolved with changeset 22959.

wrote Feb 13, 2013 at 9:27 PM

wrote May 16, 2013 at 2:53 AM