Date: Fri, 18 Nov 1994 08:15:16 -0700 To: djgpp AT sun DOT soe DOT clarkson DOT edu From: gordon AT spot DOT colorado DOT edu (Allen Gordon) Subject: Re: printf or floating point error????? I believe the following is a problem with printf. Please advise. Thanks Allen Gordon ******************************************************* #include #include void main(void) { float ans,num,inv; double ansd, numd,invd; long double ansld,invld,numld; num = 824633702441.0; numd = ( double)824633702441.0; numld = (long double) 824633702441.0; inv = 1.0 / num; invd = (double) 1.0 / numd; invld = (long double) 1.0 / numld; ansld = numld * invld; ansd = numd*invd; ans = num * inv; printf("%20.18g\t%20.18g\t%20.18g \n", num, inv, ans); printf("%20.18g\t%20.18g\t%20.18g \n", numd,invd, ansd); printf ("%20.18Lg\t%20.18Lg\t%20.18Lg \n",numld,invld,ansld); } RESULTS: 824633720832 1.21265963850397673e-12 1 824633702441 1.21265962940866734e-12 0.999999999999999822 -1.99993148818612099 -1.10101976021228642e-278 3.46811918756373849e-310 Under turbo c(dos) version 3.0, I got: 824633720832 1.21265963850397673e-12 1 824633702441 1.21265962489115788e-12 0.999999996274709813 824633702441 1.2126596248911578e-12 0.999999996274709702 Thanks Allen