Question: Floating point and printf()

Chris Torek chris at mimsy.umd.edu
Wed Dec 13 17:10:20 AEST 1989


In article <2777 at cbnewsj.ATT.COM> asd at cbnewsj.ATT.COM (adam.denton) writes:
>I would like to know what the CORRECT format specifier is in printf()
>to print out values of type `float' and values of type `double'.

`%e', `%f', and `%g'.

>According to K&R2, page 244, the format specifiers e, f, and g all default
>to type `double'.  K&R2 does not mention the use of the `l' (lower case ell)
>in regard to floating point.

K&R2 does, however, mention (possibly elsewhere) that it is NOT POSSIBLE
to pass a `float' to a variadic function.  All such values are converted
to double precision in the absence of a prototype, or in the presence of
a variadic prototype.

>Now in the Turbo C 2.0 reference manual under ...printf(), it is mentioned
>that the letter ell can be prefixed to e, f, or g to indicate that the
>argument is type `double.'

... which is incredibly misleading, since the letter ell can be omitted
to indicate that the argument is type double as well.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at cs.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.lang.c mailing list