Float Double Parameters

Gregory Smith greg at utcsri.UUCP
Tue Apr 1 18:17:22 AEST 1986


In article <5216 at alice.uUCp> ark at alice.UucP (Andrew Koenig) writes:
>>X3J11 says "arguments that have type float are promoted to double". Too bad.
>
>Ansi C also lets you declare types of formal parameters to externals:
>
>	extern float f(float x);
>in which case:
>	f(1);		/* 1 is converted to float */
>	f(1.0);		/* 1.0 is converted to float */
>
>are both OK.

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.

If the above *is* correct, then apparently I can pass a float to a function
( provided it is not defined in the current file (!?!?!?!) ) but it is *not*
possible to write a function that accepts a float as a parameter.

C is strange, but not that strange - I suspect Mr. Koenig has read something
into the standard that is not there.  If anyone has reliable information
to the contrary, let us know...

-- 
"If you aren't making any mistakes, you aren't doing anything".
----------------------------------------------------------------------
Greg Smith     University of Toronto      UUCP: ..utzoo!utcsri!greg



More information about the Comp.lang.c mailing list