Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!wuarchive!psuvax1!rutgers!att!cbnewsj!asd From: asd@cbnewsj.ATT.COM (adam.denton) Newsgroups: comp.lang.c Subject: Question: Floating point and printf() Message-ID: <2777@cbnewsj.ATT.COM> Date: 11 Dec 89 16:07:49 GMT Distribution: na Organization: AT&T Bell Laboratories Lines: 30 Here's a seemingly easy question. It has been nagging me for quite a while. 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'. 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. Reading the description, it doesn't appear that there's any way to tell printf() you're passing it a `float' instead of `double.' K&R2: printf("%f", 3.1416) type=`double.' K&R2: printf("%lf", 3.1416) not discussed 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.' I take this to mean that, if you don't include the ell, then it assumes the argument is type `float' (since capital L is available for `long double'). TC2: printf("%lf", 3.1416) type=`double' TC2: printf("%f", 3.1416) referred to as `floating point' only; I assume it's `float.' Am I right? So...what gives? Is there a conflict here? Did K&R2 omit anything? What does pANS say?? Enquiring minds want to know! Adam S. Denton asd@mtqua.ATT.COM ...!att!mtqua!asd