14,301,527 members
Rate this:
See more:
Am I right in thinking that in a little endian 4 byte signed int, the sign is held in the top bit of the 4th byte? i.e.(in binary) xxxxxxxx xxxxxxxx xxxxxxxx 1xxxxxxx is negative and xxxxxxxx xxxxxxxx xxxxxxxx 0xxxxxxx is positive?

What I have tried:

Since I only *suspect* that the data I am looking at is signed, rather than *knowing* I am uncertain as to how to prove things either way.
Posted
Updated 16-Jan-19 7:53am

Rate this:

## Solution 1

OH, if you are wanting to determine how endian-ness works in VB you could try something like:
(Use your values and try it out.)
```Dim a() As Byte = { &H1C }
Dim b(3) As Byte
If BitConverter.IsLittleEndian Then
b(0) = a(0)
Else
b(3) = a(0)
End If
Dim key As Integer = BitConverter.ToInt32(b, 0)```

Found at: Change byte array to integer in VB.net - Stack Overflow[^]

```Private Function BArrayToInt(ByRef bArray() As Byte) As Integer
Dim iReturn As Integer
Dim i As Integer
For i = 0 To UBound(bArray) - LBound(bArray)
iReturn = iReturn + bArray(i) * 2 ^ i
Next i

BArrayToInt = iReturn

End Function```

from : bytearray - Byte Array to a Signed Integer in VB6 - Stack Overflow[^]
v2
Member 14100511 17-Jan-19 0:58am

Thanks raddevus. I should have said I'm working in VB6 as befits my age.
I don't see how the VB6 solution is going to return a signed value, but will give it a try.

Mostly my question is about where the sign bit is held in a little endian 4 byte number.