leo@atcmp.nl (@ Leo Willems) (02/07/91)
When compiling the next program under cfron ports 2.0 and 2.1 the output
in both cases is not what I expect it to be:
#include <iostream.h>
main()
{
cout.setf(ios::showpoint);
cout.precision(3);
cout << 0.1 << endl << 1.1 << endl;
}
Output:
0.100
1.10
The extra 0 from 0.1 is a little too much :-(
Is this a known bug, or am I wrong? In both cases, is there a fix?
Thanks.
Leo
--
Leo Willems Internet: leo@atcmp.nl
AT Computing UUCP: mcsun!hp4nl!kunivv1!atcmpe!leo
P. O. Box 1428 6501 BK Nijmegen, The Netherlands
Phone: +31-80-566880 Fax: +31-80-555887
leo@atcmp.nl (@ Leo Willems) (02/08/91)
In article <875@atcmpe.atcmp.nl>, leo@atcmp.nl (@ Leo Willems) writes: > When compiling the next program under cfron ports 2.0 and 2.1 the output > in both cases is not what I expect it to be: > > #include <iostream.h> > > main() > { > cout.setf(ios::showpoint); > cout.precision(3); > > cout << 0.1 << endl << 1.1 << endl; > } > > Output: > > 0.100 > 1.10 > > The extra 0 from 0.1 is a little too much :-( > > Is this a known bug, or am I wrong? In both cases, is there a fix? Since a while I think it is not a bug, I didn't understand ios::precision(). What I want is this: given some floats I want them to be inserted in a stream in a columnwise fashion (like printf "%8.3f") i.e.: .... some statements setting the format cout <<setw(8) << 123.45 << " " <<setw(8) << 121.1 << endl; cout <<setw(8) << 23.45 << " " <<setw(8) << 21.1 << endl; cout <<setw(8) << 0.1 << " " <<setw(8) << 1.0 << endl; giving: 123.450 121.100 23.450 21.100 0.100 1.000 Is this possible with ios formatting capabilities? Thanks Leo -- Leo Willems Internet: leo@atcmp.nl AT Computing UUCP: mcsun!hp4nl!kunivv1!atcmpe!leo P. O. Box 1428 6501 BK Nijmegen, The Netherlands Phone: +31-80-566880 Fax: +31-80-555887