home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #23 / NN_1992_23.iso / spool / sci / math / 13357 < prev    next >
Encoding:
Text File  |  1992-10-16  |  1.5 KB  |  36 lines

  1. Newsgroups: sci.math
  2. Path: sparky!uunet!microsoft!wingnut!stevesa
  3. From: stevesa@microsoft.com (Steve Salisbury)
  4. Subject: Re: Calculating pi: help!
  5. Message-ID: <1992Oct16.200112.22555@microsoft.com>
  6. Date: 16 Oct 92 20:01:12 GMT
  7. Organization: Microsoft Corporation
  8. References: <1992Oct14.112018.19335@kth.se> <7567@charon.cwi.nl> <1992Oct15.103812.7219@kth.se>
  9. Lines: 25
  10.  
  11. In article <1992Oct15.103812.7219@kth.se> TordM@VanA.PhySto.SE writes:
  12. >In article <7567@charon.cwi.nl>, dik@cwi.nl (Dik T. Winter) writes:
  13. >
  14. >>Compiler bug?  Try main(){printf("%.4d\n",0);} if this program does not
  15. >>print 0000 your compiling system has a bug.
  16. >
  17. > compiler bug indeed; yet another reason not to use "c" :-)
  18.  
  19. Pardon me, but the compiler does NOT handle printf() format strings --
  20. that's a C run-time library function.  This is in important distinction.
  21. C run-time libraries are usually closely coupled with a given compiler,
  22. but that's not the same thing as being "part of" the compiler.
  23.  
  24. According to the ANSI C standard, %.4d should emit at least four digits
  25. (using leading zeroes), but this functionality was NOT in the older,
  26. de facto C standard, the C book by Kernighan & Ritchie.
  27.  
  28. The more portable and dependable solution would be: printf ("%04d\n",...
  29.  
  30. Steve Salisbury
  31.  
  32. *  Obligatory  *|-------------------------------------------------------|
  33. *  disclaimer  *| The views expressed in this message are my own and in |
  34. * required  by *|   no way reflect the views of Microsoft Corporation.  |
  35. * my employer: *|-------------------------------------------------------|
  36.