Arithmetic Data Types


Java solves a major portability problem that has plagued C and C++ by simply defining it away! The primative arithmetic data types are all precisely defined, no ranges, no inequalities, no "definitions" such as, "int may not be smaller than short."
Here are the signed integer types:

byte
This is a signed 8-bit quantity (-128 to 127)
short
This is a signed 16-bit quantity (-32768 to 32767)
int
This is a signed 32-bit quantity (aprox. -2.1 billion to 2.1 billion)
long
This is a signed 64-bit quantity (aprox. -very big to very big)

Here are the floating point types (IEEE-754):
float
This is a "single precision" 32 bit floating point number.
double
This is a "double precision" 64 bit floating point number.

And Now For Two Things Completely Different

char:(Unicode)
Characters in Java are 16 bit unsigned integers (!) that are mapped into the Unicode Worldwide Character Standard. Presently, 34,168 distinct coded characters are supported. These represents most of the major languages of the world from Arabic to Thai. There are also sets of Numbers, Technical Symbols, Dingbats, and other "standard characters". ASCII is mapped as \u00xx. This leaves room for about 30,000 additional characters to be encoded.
boolean:
Java implements a 2-valued type, true/false for conditional statements. In particular, the old stand-by of C and C++, "test for 0 or non-zero", no-longer works!
int i;
.
. ..code..
if(i=
exp){something}


Next | Back