datatypes

In C/C++ datatypes are dependant on the system you are compiling for.
This can be 16 bit, 32 bit or 64 bit, and Big Endian or Little Indian.
For 64bit systems it even depends on the data model.
In Java this is all standardised.
An integer is always 32 bit and data is always Big Endian.
Also there are no unsigned types in java, all types are signed, even bytes.
This can be annoying and confusing.
The following table gives an overview for a 32bit i386 and a 64bit AMD64 system:

datatypes on a 32bit i386 system
type Java C/C++
8bit unsigned - unsigned char
8bit signed byte char
16bit unsigned - unsigned short
16bit signed short short
32bit unsigned - unsigned int
32bit signed int int
64bit unsigned - unsigned long long
64bit signed long long long
32bit floating point float float
64bit floating point double double
datatypes on a 64bit AMD64 system
type Java C/C++
8bit unsigned - unsigned char
8bit signed byte char
16bit unsigned - unsigned short
16bit signed short short
32bit unsigned - unsigned int
32bit signed int int
64bit unsigned - unsigned long
64bit signed long long
32bit floating point float float
64bit floating point double double

In C and C++, you can use char* and casts to convert simple datatypes into bytes. In java this is not possible. Luckily the java.nio package exists. This contains among things the class ByteBuffer, making data conversions alot easier.

To Be continued…!