home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / gnu / g / lib / bug / 793 < prev    next >
Encoding:
Internet Message Format  |  1993-01-21  |  1.7 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!cis.ohio-state.edu!cygnus.com!bothner
  2. From: bothner@cygnus.com
  3. Newsgroups: gnu.g++.lib.bug
  4. Subject: Re: 2.3: ios::showpos overeager on unsigneds
  5. Date: 21 Jan 1993 18:21:34 -0500
  6. Organization: GNUs Not Usenet
  7. Lines: 40
  8. Sender: daemon@cis.ohio-state.edu
  9. Approved: bug-lib-g++@prep.ai.mit.edu
  10. Distribution: gnu
  11. Message-ID: <9301212052.AA15114@cygnus.com>
  12. References: <9301201711.AA25469@cs.rice.edu>
  13.  
  14. > A careful reading of Stroustrup, "C++ prog lang", 2nd ed., page 340
  15. > indicates that the showpos attribute of an ostream causes the printing
  16. > of '+' signs for positive ints.
  17.  
  18. Do not count on Stroustrup to be accurate or complete when it comes
  19. to the iostream library.
  20.  
  21. > With Sun C++, this program
  22. > ======================================================================
  23. > #include <iostream.h>
  24. > int main(int, char*[])
  25. > {
  26. >   unsigned u = 1;
  27. >   cout.setf(ios::showpos);
  28. >   cout << u << endl;
  29. >   return 0;
  30. > }
  31. > ======================================================================
  32. > prints
  33. > 1
  34. > as seems appropriate, since u is not a positive int.  With (patched)
  35. > g++-2.3.3 and (patched) libg++-2.3, the same program prints
  36. > +1
  37.  
  38. I disagee: 1 is a positive int.
  39.  
  40. However, my ANSI draft is unclear.  It says:
  41.  
  42.     If i is positive and showpos is on, decimal conversion converts
  43.     it to a plus signed (+) followed by decimal digits.  The other
  44.     conversions treat all values as unsigned.
  45.  
  46. It might *possibly* be interpreted to imply that unsigned conversion
  47. should not show a '+'.  I don't think that is the most natural
  48. interpretation, but I will ask for a clarification.
  49.  
  50.     --Per Bothner
  51. Cygnus Support     bothner@cygnus.com
  52.  
  53.