/* Program to illustrate that you can't add accurately in floating point. Written by: Dan Stearns Date: fall 2000 Notes: The use of double doesn't solve the problem. */ #include main () { float a = 0.0; float b = 1.00; int counter = 0; /* add 100 pennies */ for (counter=1; counter <= 100; counter++) { a = a + .01; } /* check if the sum of 100 pennies == one dollar */ if ( a == b) printf ("%s\n", "equal"); else printf("%s\n", "not equal"); printf ("%f\n",a); }