home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!gatech!darwin.sura.net!convex!news.utdallas.edu!corpgate!brtph560!brtph597!markham
- From: markham@brtph597.bnr.ca (Andrew Markham P205)
- Subject: Help with floating point I/O (well, really O)
- Message-ID: <1992Dec22.200420.1734@brtph560.bnr.ca>
- Sender: news@brtph560.bnr.ca (Usenet News)
- Organization: BNR Inc. RTP, NC
- Date: Tue, 22 Dec 1992 20:04:20 GMT
- Lines: 38
-
- The following C++ code:
-
- #include <iostream.h>
- #include <iomanip.h>
-
- main()
- {
- float a = 0.1, b=0.12, c=0.123, d=0.0;
-
- cout << setprecision(3) << setw(6) << a << endl;
- cout << setprecision(3) << setw(6) << b << endl;
- cout << setprecision(3) << setw(6) << c << endl;
- cout << setprecision(3) << setw(6) << d << endl;
- }
-
- Prints the following output:
-
- > a.out
- 0.1
- 0.12
- 0.123
- 0
- >
-
- How do I get it to print the following?
-
- > a.out
- 0.100
- 0.120
- 0.123
- 0.000
- >
-
- Thanks.
-
- --
- Andrew W. Markham (markham@bnr.ca)
- Bell Northern Research, Inc.
-