Path: utzoo!utgpu!jarvis.csri.toronto.edu!torsqnt!hybrid!robohack!druid!darcy From: darcy@druid.uucp (D'Arcy J.M. Cain) Newsgroups: comp.lang.c Subject: Re: log10(8) Message-ID: <1990Feb28.160637.3754@druid.uucp> Date: 28 Feb 90 16:06:37 GMT References: <3244@servax0.essex.ac.uk> <1460@amethyst.math.arizona.edu> <90058.153054CMH117@psuvm.psu.edu> Reply-To: darcy@druid.UUCP (D'Arcy J.M. Cain) Organization: D'Arcy Cain Consulting, West Hill, Ontario Lines: 34 In article <90058.153054CMH117@psuvm.psu.edu> CMH117@psuvm.psu.edu (Charles Hannum) writes: >In article , meissner@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@druid) | Thank goodness we don't get all D'Arcy Cain Consulting | the government we pay for. West Hill, Ontario, Canada | (416) 281-6094 |