This applet does a single precision (float, a 32-bit IEEE data type) and double precision (double, a 64-bit IEEE data type) calculation that adds the floating point constant 0.1 to itself 100 times. This result is compared to 100*0.1, a calculation that gives exactly 10.0 in properly rounded arithmetic.
This comparison shows the effect of accumulated round-off error when doing addition with any value that appears exact in decimal but whose binary floating-point value repeats indefinitely and must, therefore, be rounded or chopped when stored in a digital computer.
I have links below to the source code for these "he can write Fortran in any language" routines, er, classes.
The second of these is run from a system prompt by entering
java TstArithafter you have compiled it with
javac TstArith.javaon any fully compliant java1.0 development system.