// FloatRoundErr.java: shows that float does not represent the value exactly. class FloatError { public static void main(String[] arg) { // ******************************************* // Demo computation in float representation // ******************************************* float f1, f2; f1 = 0.2f + 0.2f + 0.2f + 0.2f + 0.2f + 0.2f + 0.2f + 0.2f + 0.2f + 0.2f; f2 = 2.0f; System.out.println (f1); System.out.println (f2); // f1 SHOULD be equal to f2 !!! if ( f1 == f2 ) { System.out.println ("f1 == f2"); } else { System.out.println ("f1 != f2"); } } }