/* comparingFloats.c * CS201 - by RA */ #include #include int main(void) { float x,y,p,t; x=1.0; y=3.0; p=x/y; t=0.333333; p=p-t; printf("\nx=1.0; y=3.0; p=x/y; t=0.333; p=p-t; have been completed!\n"); printf("Values are (or maybe I should rather say \"they look like\"):\nx=%f; y=%f; t=%f; p=%f\n\n", x, y, t, p); if (p==0.0) printf("Result of (p==0.0) test is recognized as TRUE, since (p==0.0) returned: %d", p==0.0); else printf("Result of (p==0.0) test is recognized as FALSE, since (p==0.0) returned: %d", p==0.0); printf("\n\n"); if ( (fabsf(p)- 0.0) < 0.000001 ) printf("Result of ((fabsf(p)-0.0)<0.000001) test is recognized as TRUE, the returned value is: %d\n", ((fabsf(p)-0.0)<0.00001 )); else printf("Result of ((fabsf(p)-0.0)<0.000001) test is recognized as FALSE, the returned value is: %d\n", ((fabsf(p)-0.0)<0.000001)); printf("\n"); exit(0); }