Answered by:
Show the whole number

Question
-
Hi,
I display the line using these
struct nameval { char fld_nm[30]; float fld_val; }; nameval binrec; int main() { std::vector<nameval> records; ... out1 << binrec.fld_nm << '\t' << setw(10) << binrec.fld_val << endl; ...
while this is the float shown there in the output line
7.19597e+006
how to exactly show the whole number there?
Many Thanks & Best Regards, Hua Min
- Edited by Jackson_1990 Thursday, December 19, 2013 9:12 AM
Thursday, December 19, 2013 9:12 AM
Answers
-
out1 << binrec.fld_nm << '\t' << setw(10) << fixed << binrec.fld_val << endl;
how to adjust the decimal numbers there?Examples:
out1 << binrec.fld_nm << '\t' << setw(10) << setprecision(2) << fixed << binrec.fld_val << endl; out1 << binrec.fld_nm << '\t' << setw(10) << setprecision(0) << fixed << binrec.fld_val << endl;
- Wayne
- Marked as answer by Jackson_1990 Friday, December 20, 2013 6:15 AM
Friday, December 20, 2013 4:09 AM
All replies
-
while this is the float shown there in the output line
7.19597e+006
how to exactly show the whole number there?
What do you mean with "whole number"?
Do you want
7195970 displayed instead of 7.19597e+006?
If this was your question this amy help:
http://msdn.microsoft.com/en-us/library/8bbhbaew.aspx
Best regards
Bordon
Note: Posted code pieces may not have a good programming style and may not perfect. It is also possible that they do not work in all situations. Code pieces are only indended to explain something particualar.Thursday, December 19, 2013 9:22 AM -
struct nameval { char fld_nm[30]; float fld_val; }; nameval binrec; int main() { std::vector<nameval> records; ... out1 << binrec.fld_nm << '\t' << setw(10) << binrec.fld_val << endl; ...
while this is the float shown there in the output line
7.19597e+006
how to exactly show the whole number there?
Perhaps you want this:
out1 << binrec.fld_nm << '\t' << setw(10) << fixed << binrec.fld_val << endl;
- Wayne
Thursday, December 19, 2013 10:25 AM -
Many thanks all.
Wayne,
I now get this
719597.000000
by this line
out1 << binrec.fld_nm << '\t' << setw(10) << fixed << binrec.fld_val << endl;
how to adjust the decimal numbers there?Many Thanks & Best Regards, Hua Min
Friday, December 20, 2013 2:58 AM -
out1 << binrec.fld_nm << '\t' << setw(10) << fixed << binrec.fld_val << endl;
how to adjust the decimal numbers there?Examples:
out1 << binrec.fld_nm << '\t' << setw(10) << setprecision(2) << fixed << binrec.fld_val << endl; out1 << binrec.fld_nm << '\t' << setw(10) << setprecision(0) << fixed << binrec.fld_val << endl;
- Wayne
- Marked as answer by Jackson_1990 Friday, December 20, 2013 6:15 AM
Friday, December 20, 2013 4:09 AM