home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!cis.ohio-state.edu!cygnus.com!bothner
- From: bothner@cygnus.com
- Newsgroups: gnu.g++.lib.bug
- Subject: Re: 2.3: ios::showpos overeager on unsigneds
- Date: 21 Jan 1993 18:21:34 -0500
- Organization: GNUs Not Usenet
- Lines: 40
- Sender: daemon@cis.ohio-state.edu
- Approved: bug-lib-g++@prep.ai.mit.edu
- Distribution: gnu
- Message-ID: <9301212052.AA15114@cygnus.com>
- References: <9301201711.AA25469@cs.rice.edu>
-
- > A careful reading of Stroustrup, "C++ prog lang", 2nd ed., page 340
- > indicates that the showpos attribute of an ostream causes the printing
- > of '+' signs for positive ints.
-
- Do not count on Stroustrup to be accurate or complete when it comes
- to the iostream library.
-
- > With Sun C++, this program
- > ======================================================================
- > #include <iostream.h>
- >
- > int main(int, char*[])
- > {
- > unsigned u = 1;
- > cout.setf(ios::showpos);
- > cout << u << endl;
- > return 0;
- > }
- > ======================================================================
- > prints
- > 1
- > as seems appropriate, since u is not a positive int. With (patched)
- > g++-2.3.3 and (patched) libg++-2.3, the same program prints
- > +1
-
- I disagee: 1 is a positive int.
-
- However, my ANSI draft is unclear. It says:
-
- If i is positive and showpos is on, decimal conversion converts
- it to a plus signed (+) followed by decimal digits. The other
- conversions treat all values as unsigned.
-
- It might *possibly* be interpreted to imply that unsigned conversion
- should not show a '+'. I don't think that is the most natural
- interpretation, but I will ask for a clarification.
-
- --Per Bothner
- Cygnus Support bothner@cygnus.com
-
-