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!watmath!clyde!burl!ulysses!bellcore!decvax!decwrl!sun!guy From: guy@sun.uucp (Guy Harris) Newsgroups: net.lang.c Subject: Re: Float Double Parameters Message-ID: <3439@sun.uucp> Date: Thu, 3-Apr-86 13:27:07 EST Article-I.D.: sun.3439 Posted: Thu Apr 3 13:27:07 1986 Date-Received: Sat, 5-Apr-86 11:14:45 EST References: <2600042@ccvaxa> <5216@alice.uUCp> <2442@utcsri.UUCP> Organization: Sun Microsystems, Inc. Lines: 30 > OK, but doesn't "extern float f(float x)" really mean > "extern float f( double x )"? I.e. '1' and '1.0' are passed as doubles to > f in the above examples. I don't know, but I suppose this feature has been > added only to allow the compiler to check ( and convert when applicable ) > the parameter types. Mr. Koenig is correct. According to the August 11, 1985, X3J11 draft: C3.2.2 Function calls ... Also, *if no function prototype declarator is in scope*, the integral promotions are performed and arguments that have type "float" are promoted to "double". ("italics" mine) ... If a function prototype declarator is in scope, the arguments are compared with the formal parameters. ...The types must be such that each formal parameter may be initialized by the coresponding argument, and the arguments are converted accordingly. Yes, prototypes were added to allow the compiler to check parameter types and convert where applicable. However, this and other changes to the C language in the draft proposed ANSI standard permit the automatic integral and "float" to "double" promotions to be gotten rid of in most circumstances; there was no good reason *not* to eliminate those conversions in the case of functions with full declarations, and good reason to do so. -- Guy Harris {ihnp4, decvax, seismo, decwrl, ...}!sun!guy guy@sun.arpa (yes, really)