Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site ecrhub.UUCP Path: utzoo!hcrvax!ecrhub!david From: david@ecrhub.UUCP (David M. Haynes) Newsgroups: net.lang.c Subject: Re: how has C bitten you? Message-ID: <245@ecrhub.UUCP> Date: Wed, 7-Aug-85 13:30:05 EDT Article-I.D.: ecrhub.245 Posted: Wed Aug 7 13:30:05 1985 Date-Received: Thu, 8-Aug-85 05:42:22 EDT References: <302@brl-tgr.ARPA>, <4081@alice.UUCP> <243@ecrhub.UUCP>, <55@drutx.UUCP> Organization: Emerald City Research, Toronto Lines: 54 >> One of my all time favourites is the non-orthagonality between ^^^^^^^^^^^^^^^^^ >> scanf and printf. Especially the following: >> >> scanf("%D %F", long, double); or >> scanf("%ld %lf", long, double); >> vs. >> printf("%ld %f", long, double); >> >> Why no %F or %D on printf? >> And why %lf vs %f? fun! >> > >scanf can be given a pointer to any data type: > char (string) > int, > long, > float, > double; > >When you put arguments on stack, expansion rules are followed. > > char => int > float => double > >So, printf can never get a float as an argument, it always gets a double. >Therefore, %lf or %F are meaningless to printf. > >Note that printf does support %d and %ld, and will happily screw up if >there is a disagreement between the args and their specification in the >format string. ie. %d given a long arg, or %ld given a short. (machine >dependent!!). >Brian Jones aka {ihnp4,}!drutx!qwerty @ AT&T-IS 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? B.T.W. This originally was in response to the "How has C bitten you?" question but has digressed at this point. Apologies and I'll mail further discussion directly. -- -------------------------------------------------------------------------- David M. Haynes Exegetics Inc. ..!utzoo!ecrhub!david "I am my own employer, so I guess my opinions are my own and that of my company."