Data Type Name | Size | Data Type |
---|---|---|
int |
4 byte | integer type |
short | 2 bytes | integer type Do not use |
long | 8 bytes | integer type |
byte | 1 byte | integer type (-127 to +128) |
char | 2 bytes (because of Unicode) | one character: 'a' or '\n'. Not "a" 'ab' or "ab" |
float | 4 bytes (7 decimal places) | floating point / real number Probably no need to use this |
double | 8 bytes (14 decimal places) | floating point / real number |
boolean | True/False (not equal to 1 or 0) |
Strange stuff: if x is NotaNumber and y = x; y==x is still false. One NaN is never equal to another NaN!
Type in and run this program: DoubleMath.java
Entering other base numbers:
int i = 5;
int j = 2;
double result;
result = i / j; //integer division; result=2
result = (double) i / (double) j //real division; result=2.5
Java will implicity cast operants in a mixed expression to match the precision of the variable storing the result.
==========================