Java Applet
to demonstrate properties of
Floating-Point Arithmetic

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.

Your browser does not support Java, or Java is not enabled. Sorry!

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 TstArith
after you have compiled it with
      javac TstArith.java
on any fully compliant java1.0 development system.