Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84 SMI; site sun.uucp Path: utzoo!linus!philabs!prls!amdimage!amdcad!decwrl!sun!guy From: guy@sun.uucp (Guy Harris) Newsgroups: net.lang.c Subject: Re: %F vs. %lf and %D vs. %ld in printf/scanf Message-ID: <2651@sun.uucp> Date: Fri, 16-Aug-85 04:43:02 EDT Article-I.D.: sun.2651 Posted: Fri Aug 16 04:43:02 1985 Date-Received: Tue, 20-Aug-85 01:27:45 EDT References: <302@brl-tgr.ARPA>, <4081@alice.UUCP> <243@ecrhub.UUCP>, <55@drutx.UUCP> <245@ecrhub.UUCP> Organization: Sun Microsystems, Inc. Lines: 27 > Yes, I did realize that, but (and this is where the show really starts..) > the problem I reported is one of NON-ORTHAGONALITY not implementation. > Your explanation is quite correct, but why should I (as a programmer) > have to worry about translation to stack? Why doesn't printf take > %F and %D and translate for me so that the orthagonality of the two > system calls (which are considered by most to be related functions) > is the same? Because there is a very natural (and very useful) interpretation for %X and %E which are *not* equivalent to %lx and %le - namely, print the number with upper-case "A-F" or upper-case "E". This approach is taken by System V and by the ANSI C standard (at least in the November 1984 draft (and by Sun 4.2, and, I believe, everybody's 4.3). If you use "%ld" and "%lf" in both "printf" and "scanf", you will have code that works on all those systems (and, I believe, on V7 as well); if you use %D or %F, you have code that doesn't work on some of those systems and doesn't work one bit better on the others. (The ANSI C standard, November 1984 draft, states, BTW, that "l" applied to "f", "e", or "g" in a "printf" control string is ignored, since you can't pass a "float" without it being widened into a double; this is implemented by 4.2 VAX, 4.2 Sun, and S5.) If you use "%l" for doubles and longs, and "%" for floats and ints, you achieve most of the orthogonality you want. If "printf" treated "%h" just like "%", you'd get the rest of the orthogonality, since you'd use "%h" for shorts. Guy Harris