/* prog1a.c -- Determine Machine Epsilon Written Sep 20, 2002 by Eric Olson for Mathematics 483 For more information see Step 3 in First Steps in Numerical Analysis, 2nd Edition, by Hosking, Joe, Joyce and Turner */ #include #include #define REAL double REAL maxdelta(REAL x){ REAL a,b,delta,deold,r1; a=0.0; if(x>0.0) b=x; else b=-x; deold=a; for(;;){ delta=(a+b)/2.0; if(deold==delta) break; r1=x+delta; if(r1==x) a=delta; else b=delta; deold=delta; } return a; } REAL data[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 10.0, 100.0, 1000.0 }; main(){ int i; REAL x,delta; printf("prog1a.c -- Determine Machine Epsilon\n\n"); printf("Using %d byte floating point.\n\n", sizeof(REAL)); for(i=0;i