Hi!
Im am porting some stuff from C# to JAVA and I need a class that can convert bytes to primitives, just lite BitConverter in .NET can.
As I just posted here, I noted that my computer uses Little-Endian (Intel) and BitConverter works as expected:
// C# code
byte[] b2 = new byte[] { 0, 1 };
short b2short = BitConverter.ToInt16(b2, 0);
the b2short == 256 as expected.
Well, I needed a "BitConverter" in JAVA and found this piece of code. However, when I try it in JAVA it seems to me that the methods interpret the byte arrays as Big-Endian. JAVA-code:
// JAVA code
byte[] b2 = new byte[] { 0, 1 };
short b2short = MyFoundConverter.BitConverter.toShort(b2, 0);
In this case, b2short == 1 and that seems to me like Big-Endian.
The question: Can someone, that knows those bitwise operators, tell me if indeed the code found on this webpage is interpreting the byte array as Big-Endian?
If so, is there an easy way to make it Little-Endian?
Regards