log10(8)
D'Arcy J.M. Cain
darcy at druid.uucp
Thu Mar 1 03:06:37 AEST 1990
In article <90058.153054CMH117 at psuvm.psu.edu> CMH117 at psuvm.psu.edu (Charles Hannum) writes:
>In article <MEISSNER.90Feb27104552 at curley.osf.org>, meissner at osf.org (Michael
>Meissner) says:
>>
>>| Try printf"%lf",l); after all l is declared to be a double!!!!!!!!
>>
>>Sigh. Printf is a varargs function. This means that there is no way
>>a 'float' can be passed to it. Thus %f and %lf are synomous.....
>
>As I don't have access to my copy of K&R2 until Monday, could you please point
>me to a specific reference?
>
That is true for the following code:
...
int foo(float x, double y);
...
foo(3, 4);
In this case 3 is passed as a float and 4 is passed as a double. In the
case of printf the prototype doesn't specify the types of the argument
list (specified with ellipsis notation to show variable arguments) and
therefore "... suffer default argument promotion ..." (K&R2 pp.202).
>BTW: I know of at least one compiler that *does* pass floats as floats, not
> doubles.
>
That compiler is broke if it passes floats to printf.
--
D'Arcy J.M. Cain (darcy at druid) | Thank goodness we don't get all
D'Arcy Cain Consulting | the government we pay for.
West Hill, Ontario, Canada |
(416) 281-6094 |
More information about the Comp.lang.c
mailing list