fprintf: rationale for negative precision behavior
Mike Vermeulen
mev at hpfcso.HP.COM
Fri Jul 20 02:26:18 AEST 1990
I received no responses to an earlier posting concerning the rationale for
fprintf behavior when given a negative precision (see also X3.159-1989, section
4.9.6.1, fprintf, page 133, line 28). Let me try again:
Question #1. My interpretation of X3.159-1989 is that the following program
should print 3.141590e+00. Do you agree with this
interpretation? This interpretation is different from SVID which
expects 3e+00.
#include <stdio.h>
void main(){
printf("%.*e\n",-1,3.14159);
}
Question #2. When comparing the 5/13/88 draft with the 12/7/88 draft, there
are several changes. The standard used to say (X3J11/88-090, page 129)
-------------------------
The precision takes the form of a period (.) followed by an optional
decimal integer; if the integer is omitted it is treated as zero...
A negative precision argument is taken as if were missing.
-------------------------
The standard was changed to say (X3J11/88-159, page 133):
-------------------------
The precision takes the form of a period (.) followed by either an asterisk
* (described later) or by an optional decimal integer; if only the period
is specified, the precision is taken as zero...
A negative precision argument is taken as if the precision were omitted.
-------------------------
If I read the 5/13/88 draft equating "missing == omitted" then it
looks like X3J11 changed the semantics of fprintf between these two
drafts. Is this correct? Did X3J11 change the behavior of fprintf
with this edit? If so, why, who did it and what was the rationale
for the change? If not, what am I missing in my interpretation of the
5/13/88 draft? Was this issue discussed at an X3J11 meeting? Was the
divergence with SVID intentional?. Was there a divergence of existing
practice in this area?
Question #3. If this notes group is not the correct place to ask these
questions, who can I send them to?; particularly to understand the
edits between 5/13/88 and 12/7/88.
--mev, mev%hpfcrt at hplabs.hpl.hp.com
More information about the Comp.std.c
mailing list