Arithmetic limitations

Expect the unexpected:

Figure 101. Strange things I Slide presentation
byte count = 91;   // o.K.

int i = 91;

byte count2 = i;   // Compile error: Incompatible types
                   // Required: byte Found: int

byte points = 130; // Compile error: Incompatible types
                   // Required: byte Found: int

Figure 102. Strange things II Slide presentation
final int i = 91;

byte count = i;   //  o.K.

Why not generally using float / double in favour of seemingly more limited byte, short, int, long for arithmetics?

Figure 103. Limited floating point arithmetic precision Slide presentation
Code
long lValue = 1000000001L;


float fValue = lValue;
System.out.format(" float value: %19.0f\n",  fValue * fValue);


double dValue = lValue;
System.out.format("double value: %19.0f\n", dValue * dValue);


System.out.println(" Exact value: " + lValue * lValue);
Result
 float value:  999999984306749400
double value: 1000000002000000000
 Exact value: 1000000002000000001

Figure 104. Nearest float to 0.1F Slide presentation
Code
// Trying to represent 0.1F
// Meaning of »%12.10f«: Print 10 fractional digits within a 12 character field

System.out.format("%12.10f\n", Float.intBitsToFloat(0b111101110011001100110011001100));
                                                     //            ↑
                                                     // There is nothing in between
                                                     //            ↓
System.out.format("%12.10f\n", Float.intBitsToFloat(0b111101110011001100110011001101));
Result
2.099999905 (too small)
2.100000143 (too big)

Figure 105. FloatConverter Slide presentation
FloatConverter