Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!samsung!munnari.oz.au!bruce!goanna!ok From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) Newsgroups: comp.lang.fortran Subject: Re: problem with "pe" format Message-ID: <3200@goanna.cs.rmit.oz.au> Date: 8 Jun 90 11:03:32 GMT References: <90155.122858GL4@psuvm.psu.edu> <90158.091706GL4@psuvm.psu.edu> <8159@ubc-cs.UUCP> Organization: Comp Sci, RMIT, Melbourne, Australia Lines: 41 In article <8159@ubc-cs.UUCP>, buckland@cheddar.ucs.ubc.ca (Tony Buckland) writes: > In article <90158.091706GL4@psuvm.psu.edu> GL4@psuvm.psu.edu writes: > >Thanks to everyone who e-mailed me about the problem I was having with the > >"p" format specifier. As everyone noted, this really *is* standard (although > >very strange) FORTRAN behavior. > >I'd be curious to know if anyone can think of a sitution where you'd actually > >*want* the magnitude of the output to be changed like that. Several people have suggested why you would want P at all, though no-one as yet has pointed out that decimal scaling can be done by the formatting routines without _any_ extra roundoff error. As to why you would want it to be sticky, consider two facts: (a) you want pe, pf, pg, so it looks as though it might be simpler for the "p" part to be a separate formatting command (b) but you also want p10e and the like, and it's simplest to explain (and implement!) if p just sets a global variable. Another possibility would have been for everything that uses the 'p' flag to reset it to its default value, but then you'd have to write 10(p,e) rather than p,10e and unfortunately that might not interact with Fortran's rules about the last set of parens in a format just the way you would want. So my surmise is that the expectation was that if you wanted scaling you were probably printing out a table and wanted everything scaled the same way, and that if you didn't want everything scaled the same way it would be clearer if everything in the format had its own scale. A rule of thumb for keeping things straight, then, is that if you use P in a format at all, you should either put P first in the format (so you _know_ when it is set and that it applies to everything) or give each relevant item its own P -- "A 7th class of programs, correct in every way, is believed to exist by a few computer scientists. However, no example could be found to include here."