Unformatted text preview: this * example. Using 10.5 percent did show the problem. */ #include <stdio.h> int main() { float x; /* Currency calculation */ x=59.00+(10.5/100.)*59.00; printf("59.00 + 10.5 percent of 59.00 = %.10f\n", x); printf("The exact answer should be = 65.195\n"); printf("\n"); printf("Consider the effect of rounding to the nearest cent.\n"); /* I get the result 65.1949996948 which would be rounded to $65.19; * however the (exact) answer is 65.195 which would be rounded to * $65.20  a ripoff of one cent! */ return 0; }...
View
Full Document
 Three '09
 wheatland
 cent, The Register, Inexact Representation

Click to edit the document details