Float Double Parameters

Ray Swartz ray at vger.UUCP
Tue Apr 1 03:20:31 AEST 1986


> >X3J11 says "arguments that have type float are promoted to double".
> 
> Karl W. Z. Heuer (ihnp4!bentley!kwh)

X3J11 is the name of the committee standardizing the C language --
what you called ANSI C.

While it is true that floats are promoted to type double in many
cases, there are some where it isn't.  For example, the compiler
is free to use floats in expressions where such an answer doesn't
deviate from the result if doubles were used:


    junk = 1.0 + 2.0;

can be done in float.  

In addition, with the introduction of function prototypes, a float
can be passed to a function.  A function prototype declares (which
is different than defines  -- the function definition is where the
code goes) what type the function's arguments are:

  int foo(float x, int y);

now foo will see the first parameter passed as a float.

The committee has also authorized a new data type called long double
which has twice the precision of double (for all those 64 bit computers
out there).

There may be other places where float does get promoted...

Ray Swartz  (ucbvax!ucscc!v!ray)
	     CSnet (ray at ucsc.CSnet)
	     ARPA ray%vger%ucscc%uucp at ucbvax.EDU



More information about the Comp.lang.c mailing list