I posted a question in B4R forum since there were some close answers there but my issue is in B4A so am also asking in this forum.
I have an array of 4 bytes and want to convert these to a 32 bit integer
I have tried to use Byteconverter and also tried the method below. However, I don't think this is giving the right values since I need to read LittleEndian:
I tried reversing the order of the bytes (x=4 to 1) but this did not work either.
Any suggestions are well appreciated
Also I am confused with ByteConverter - If I convert an array of bytes to an array of ints can I then get the ints to one 32 bit integer? How do I do this?
Thanks
Evansus
I have an array of 4 bytes and want to convert these to a 32 bit integer
I have tried to use Byteconverter and also tried the method below. However, I don't think this is giving the right values since I need to read LittleEndian:
I tried reversing the order of the bytes (x=4 to 1) but this did not work either.
Any suggestions are well appreciated
B4X:
Dim b() as Byte
For x=1 To 4
u32 = u32 * 256 + Bit.AND(b(x), 255)
Log("x=" & x & ";U32=" & u32)
Next
Also I am confused with ByteConverter - If I convert an array of bytes to an array of ints can I then get the ints to one 32 bit integer? How do I do this?
Thanks
Evansus