Hi all,
I have a byte[] array read from a binary file.
I came up with a very easy solution which is to shift the byte depending on their position and OR it with the next byte to create my int.
example
int
test = (data[7] >> 8) | data[8];
data[7] contains 02 in hex
data[8] contains B8 in hex
the int value theoratically should be 696, becuse that is what i wrote in my file and that is what the file contains in hex 02B8. Except when i print the result i get -72!!!
i dont understand why, since 0x02 is 0010 0000 0000
and 0xB8 is 0000 1011 1000
ORing them would give the value of 696 0010 1011 1000
What do you think is the problem? i am using SDk 1.4.2_05 to generate the binary file, and using MIDP2 to read the file and convert from byte[] to int.
Thanks,
Mike