home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / c / 13541 < prev    next >
Encoding:
Text File  |  1992-09-11  |  1.3 KB  |  34 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!gatech!paladin.american.edu!darwin.sura.net!blaze.cs.jhu.edu!rhombus!wilson
  3. From: wilson@rhombus.cs.jhu.edu (Dwight Wilson)
  4. Subject: Re: Help!!! Please Read this message!?!?!?!?!...
  5. Message-ID: <1992Sep11.173009.12181@blaze.cs.jhu.edu>
  6. Sender: news@blaze.cs.jhu.edu (Usenet news system)
  7. Organization: The Johns Hopkins University CS Department
  8. References: <1992Sep9.085352.8755@vax.oxford.ac.uk> <1992Sep10.040600.27065@blaze.cs.jhu.edu> <MJN.92Sep11001608@pseudo.uucp>
  9. Date: Fri, 11 Sep 1992 17:30:09 GMT
  10. Lines: 22
  11.  
  12. In article <MJN.92Sep11001608@pseudo.uucp> mjn@pseudo.uucp (Murray Nesbitt) writes:
  13. >
  14. >wilson@rhombus.cs.jhu.edu (Dwight Wilson) writes:
  15. >
  16. >>Huh?  "%f" specifies a double not a float.  If you think about the
  17. >>promotion rule you'll realize that specifying a float would be
  18. >>nonsensical since it is not possible for an argument to printf()
  19. >>to be passed as a float!  
  20. >
  21. >    printf( "%f...%s?\n", (float)f, "Huh?" );
  22. >
  23. >It's another matter whether you'd *want* to pass a float to printf(),
  24. >but it is possible.
  25. >
  26.  
  27. This doesn't do it.  f is cast to a float, the compiler sees
  28. that it's passing a float, doesn't see a prototype and says,
  29. "Hmm, better promote this to a double".  Without a prototype,
  30. it is impossible to prevent this promotion.
  31.  
  32. -Dwight
  33.  
  34.