hbo@sbphy.physics.ucsb.edu (Howard B Owen) (02/26/91)
I have a problem that I seem to recall was discussed in this group.: Environment: Mips cc v 2.1/Ultrix v4.0/DECstation 5000 Problem: Output of doubles is garbled when mixed with other i/o statements. Example: #include <stdio.h> main() { FILE *outfile = fopen( "quantum.dat", "w" ); double energy = 0.01; printf("%f\n", energy); printf("%f\n", energy); fclose (outfile); } This program, compiled with "cc bug.c -o bug", produces the following output: 0.010000 19991592789737117000000000000000000000.000000 If the fopen and fclose statements are removed, or if a value is assigned to "energy" after the first printf, Then the output is as expected. Also, the following program displays a similar problem: #include <stdlib.h> #include <stdio.h> main() { float a= -0.1; double mu = -0.1; printf("%15.3e\n",mu); printf("%15.3e\n",a); printf("%15.3e\n",mu); } The output from this program, compiled like the last one, is: -1.000e-01 -1.000e-01 -2.353e-185 I can't believe such a severe bug could be part of a correctly configured system. We have FORTRAN v 2.1 installed, as the following excerpt from setld -i shows: F77BACKEND021 installed V2.1 Compiler Back End F77BASE021 installed F77 Programming Environment F77MAN021 installed F77 Manual Pages F77UNSUP021 installed F77 Unsupported Utilities Any help you could offer would be appreciated. Thanks, -- Howard Owen, Computer Systems Manager internet: hbo@sbphy.physics.ucsb.edu Physics Computer Services BITNET: HBO@VOODOO.BITNET University of California, Santa Barbara DECNET Internet: 45180::HBO "I am not a pay TV service!" Telephone: 805-893-8366 (work)