blog of Joost Yervante Damad
java tips for C/C++ coders
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:
|
|
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…!
| Print article | This entry was posted by Joost Damad on 13/05/2005 at 10:18, and is filed under lang:en, misc. Follow any responses to this post through RSS 2.0. Both comments and pings are currently closed. |
Comments are closed.