#include int main(void) { float fMult = (float) 1.2, fX = (float) 1.2, fOne = (float) 1.0; double dMult = (double) 1.2, dX = (double) 1.2, dOne= (double) 1.0; long double ldMult = (long double) 1.2, ldX = (long double) 1.2, ldOne= (long double)1.0; // Checking storage sizes printf("Bigs\n"); printf("%d %d %d\n", sizeof(fX), sizeof(dX), sizeof(ldX)); // Now doing to much bigger than one printf("Bigs\n"); while(dX + dOne > dX){ dX = dMult*dX; }; printf("double\t= %56.24e\n", dX); while(fX + fOne > fX){ fX = fMult*fX; }; printf("float\t= %56.24e\n", fX); while(ldX + ldOne > ldX){ ldX = ldMult*ldX; }; printf("long \t= %56.24Le\n", ldX); //Checking printf("Checking the long double:\n"); printf("long \t= %56.48Le\n", ldX); printf("long \t= %56.48Le\n", ldX+ldOne); printf("long \t= %56.48Le\n", 0.99*ldX+ldOne); printf("Checking the double:\n"); printf("double \t= %56.48e\n", dX); printf("double \t= %56.48e\n", dX+dOne); printf("double \t= %56.48e\n", (0.99*dX)+dOne); printf("Checking the float:\n"); printf("float \t= %56.48e\n", fX); printf("float \t= %56.48e\n", fX+fOne); printf("float \t= %56.48e\n", (0.99*fX)+fOne); // Now doing epsilon fX = 1; dX = 1; ldX = 1; printf("\nEpsilons\n"); while(dX + dOne > dOne){ dX = dX/dMult; }; printf("double\t= %56.24e\n", dX); while(fX + fOne > fOne){ fX = fX/fMult; }; printf("float\t= %56.24e\n", fX); while(ldX + ldOne > ldOne){ ldX = ldX/ldMult; }; printf("long \t= %56.24Le\n", ldX); printf("Checking the long double:\n"); printf("long \t= %56.48Le\n", ldOne); printf("long \t= %56.48Le\n", ldX+ldOne); printf("long \t= %56.48Le\n", ldOne); printf("long \t= %56.48Le\n", (1.14*ldX)+ldOne); printf("Checking the double:\n"); printf("double \t= %56.48e\n", dOne); printf("double \t= %56.48e\n", dX+dOne); printf("double \t= %56.48e\n", dOne); printf("double \t= %56.48e\n", (1.14*dX)+dOne); printf("Checking the float:\n"); printf("float \t= %56.48e\n", fOne); printf("float \t= %56.48e\n", fX+fOne); printf("float \t= %56.48e\n", fOne); printf("float \t= %56.48e\n", (1.14*fX)+fOne); return 0; }