6. Data types
Created Friday 20 March 2015
Primitive data types
byte short int long float double char boolean
Numeric primitive data types
short — 16 bits — -32,768 - +32,767
int — 32 bits — -2 billion - +2 billion (approximately)
long — 64 bits — -9E18 - +9E18 (approximately)
double — 64 bits — -1.7E308 - +1.7E308
Long literals end with 'L': 125L
Float literals: 3.5F
Double literals: -34.98D
The data type float has 24 bits of precision. This is equivalent to only about 7 decimal places.
Primitive data type double uses 64 bits, and has a much greater range, -1.7E+308 to +1.7E+308. It also has a much greater precision: about 15 significant decimal digits.
The char type represents a character using 16 bits (Unicode).