Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!ncar!tank!tank.uchicago.edu!arxt From: arxt@tank.uchicago.edu (patrick palmer) Newsgroups: comp.sys.amiga Subject: Manx5.0: large code, wrong answers? Keywords: Manx5.0, c language Message-ID: <8080@tank.uchicago.edu> Date: 24 Mar 90 08:47:43 GMT Sender: news@tank.uchicago.edu Reply-To: arxt@tank.uchicago.edu (patrick palmer) Distribution: na Organization: University of Chicago Lines: 64 I finally received my copy of Manx5.0, and I have been testing it out by recompiling and rerunning some old programs. Results have been worrisome. With one small program, I get the correct answer with Manx3.4 (checked by hand and checked by compiling the same code on an Elexsi and a Sun 3), but an answer that is precisely a factor of 100 smaller with Manx5.0. How can this be??? By the way, the code is almost exactly a factor of 2 larger with Manx5.0; even though the version with 3.4 was compiled with +L option and linked to -lm32 -lc32. (The Manx5.0 version is about 40% larger than the Elexsi version.) What is happening here? Are we to conclude that 5.0 gives larger code and wrong answers? I append a copy of the test program in case anyone wants to look at it. The compiler and linker options are included in the comments. (If you actually want to try yourself, plausible numerical values to enter are 5. and 1.e4.) Comments on the c coding style are probably wasted one me, but one obvious clumsy point results from following the 3.4 recommendations about avoiding scanf(). Pat Palmer (email: reply or ppalmer@oddjob.uchicago.edu) ---------------------------------- /* Manx5.0 version (declaration of atof() commented out, include */ /* compile: cc tau.c */ /* link: ln +q tau.o -lm -lc */ /* You seem to need all of these includes */ #include #include #include main() { /* float atof(); */ float tau,nu,onu,te,g,em,tthree,nusq; char inp_buf[10]; em=1.e7; /* read in numbers */ printf("Input frequency(GHz) and T \n"); nu=atof(gets(inp_buf)); printf("%f \n",nu); te=atof(gets(inp_buf)); printf("%f \n",te); /* evaluate expression */ while (nu > 0.) { g=log(4.95e-2*te*sqrt(te)/nu); tthree=te*sqrt(te); nusq=nu*nu; tau=3.009e-2*em/tthree/nusq*g; printf("tau= %e\n",tau); onu=nu; printf("Enter a new frequency (0 to quit, -1 to change Te) \n"); nu=atof(gets(inp_buf)); if(nu==-1.) { printf("Input New T \n"); te=atof(gets(inp_buf)); nu=onu; } } }