This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Bug report g++: setw() for doubles
- From: Bernd Feucht <bernd at bernd-feucht dot de>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 24 Nov 2001 16:17:18 +0100
- Subject: Bug report g++: setw() for doubles
[Get raw message]
Bug report for the g++ compiler
I'm currently using gcc version 2.95.2 19991024 (release).
The setw()-manipulator does not work properly for the output of double
numbers.
For testing I tried the following program:
#include <iostream.h>
#include <iomanip.h>
int main()
{
cout << setw(10) << 1.1 << setw(10) << 2.2 << endl;
return 0;
}
As far as I know the C++ specification, this program should type out:
" 1.1 2.2"
i.e. seven spaces before each double number to make the total length of
each output 10 characters long.
Instead, the output of the program above is:
"1.12.2"
i.e. the two numbers 1.1 and 2.2 without any spaces ahead.
The same program works well when I replace the double numbers by
integers or ""-enclosed strings. I does not work with ''-enclosed
characters (but that, I think, is normal, because the length of a
character is always one, so a field-length-manipulator is not really
needed).
If the above problem has already been fixed in a gcc version later than
2.95.2, please let me know.
As far as I remember, outputs of double numbers with the
setw()-manipulator were no problem in earlier releases of gcc. I noticed
the above stated problem when I recompiled a program written one year
ago (I don't remember with which gcc version, but I think it was
included in SuSE 7.0) with gcc version 2.95.2.
Greetings,
Bernd Feucht