public class floatTest { public static void main(String[] pars) { System.out.println(); System.out.println("Inexact results with floats"); System.out.println(); for (int i=1; i<=100; i++) { float z = 1.0f/i; if (z * i != 1.0f) { System.out.println(" " + i + "\tz: " + z + "\tz*i: " + z*i); } } } } Inexact results with floats 41 z: 0.024390243 z*i: 0.99999994 47 z: 0.021276595 z*i: 0.99999994 55 z: 0.018181818 z*i: 0.99999994 61 z: 0.016393442 z*i: 0.99999994 82 z: 0.0121951215 z*i: 0.99999994 83 z: 0.012048192 z*i: 0.99999994 94 z: 0.010638298 z*i: 0.99999994 97 z: 0.010309278 z*i: 0.99999994 Inexact results with doubles 49 z: 0.02040816326530612 z*i: 0.9999999999999999 98 z: 0.01020408163265306 z*i: 0.9999999999999999